Laravel 13 PHP Attributes: Eloquent, Queues &amp; More | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com) [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles  ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

  [ home ](https://www.msaied.com)    [ articles ](https://www.msaied.com/articles)    PHP Attributes in Laravel 13: A Comprehensive Guide        On this page       1. [  New Eloquent Model Attributes ](#new-eloquent-model-attributes)
2. [  Mass Assignment Control ](#mass-assignment-control)
3. [  Serialization Control ](#serialization-control)
4. [  Relationship and Appending Configuration ](#relationship-and-appending-configuration)
5. [  Table and Connection Configuration ](#table-and-connection-configuration)
6. [  Queue / Job Attributes ](#queue-job-attributes)

  ![PHP Attributes in Laravel 13: A Comprehensive Guide](https://cdn.msaied.com/114/2214aaa98d581cc58d287c9253cc09eb.png)

 [  Laravel ](https://www.msaied.com/articles?category=laravel)  #Laravel   #PHP   #Attributes   #Eloquent   #Queues  

 PHP Attributes in Laravel 13: A Comprehensive Guide 
=====================================================

     18 Mar 2026      3 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   New Eloquent Model Attributes  ](#new-eloquent-model-attributes)
2. [  02   Mass Assignment Control  ](#mass-assignment-control)
3. [  03   Serialization Control  ](#serialization-control)
4. [  04   Relationship and Appending Configuration  ](#relationship-and-appending-configuration)
5. [  05   Table and Connection Configuration  ](#table-and-connection-configuration)
6. [  06   Queue / Job Attributes  ](#queue-job-attributes)

 Laravel 13 marks a significant shift towards embracing PHP's attribute feature, offering a more declarative and cleaner way to configure various aspects of your application. This guide dives deep into the new attributes introduced, alongside existing ones, providing practical examples for Laravel and PHP developers.

It's important to note that these attributes are entirely optional. The traditional property-based syntax remains fully supported, ensuring backward compatibility and a smooth transition for existing projects.

New Eloquent Model Attributes
-----------------------------

Laravel 13 introduces a suite of attributes that directly replace common Eloquent model properties, streamlining model definitions.

### Mass Assignment Control

- `#[Fillable]`Previously defined using `protected $fillable`, this attribute specifies which model attributes are mass assignable.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Fillable;

    #[Fillable(['title', 'body', 'status'])]
    class Post extends Model
    {
    }

    ```
- `#[Guarded]`Replaces `protected $guarded`, defining attributes that are *not* mass assignable.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Guarded;

    #[Guarded(['id', 'is_admin'])]
    class User extends Model
    {
    }

    ```
- `#[Unguarded]`A simple marker attribute that disables mass-assignment protection entirely, equivalent to `protected $guarded = [];`.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Unguarded;

    #[Unguarded]
    class Setting extends Model
    {
    }

    ```

### Serialization Control

- `#[Hidden]`Replaces `protected $hidden`, specifying attributes to exclude from JSON serialization.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Hidden;

    #[Hidden(['password', 'remember_token'])]
    class User extends Model
    {
    }

    ```
- `#[Visible]`The inverse of `#[Hidden]`, explicitly defining attributes to include in JSON serialization, replacing `protected $visible`.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Visible;

    #[Visible(['id', 'name', 'email'])]
    class User extends Model
    {
    }

    ```

### Relationship and Appending Configuration

- `#[Appends]`Replaces `protected $appends`, automatically appending accessor results to JSON output.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Appends;

    #[Appends(['full_name', 'is_active'])]
    class User extends Model
    {
        public function getFullNameAttribute(): string
        {
            return $this->first_name . ' ' . $this->last_name;
        }
    }

    ```
- `#[Touches]`Replaces `protected $touches`, specifying parent models whose timestamps should be updated when the current model is saved.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Touches;

    #[Touches(['post'])]
    class Comment extends Model
    {
        public function post(): BelongsTo
        {
            return $this->belongsTo(Post::class);
        }
    }

    ```

### Table and Connection Configuration

- `#[Table]`A versatile attribute that consolidates configuration for `$table`, `$primaryKey`, `$keyType`, `$incrementing`, `$timestamps`, and `$dateFormat`.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Table;

    #[Table('blog_posts', key: 'post_id')]
    class Post extends Model
    {
    }

    #[Table(
        name: 'external_orders',
        key: 'uuid',
        keyType: 'string',
        incrementing: false,
        timestamps: false,
    )]
    class ExternalOrder extends Model
    {
    }

    ```
- `#[Connection]`Replaces `protected $connection`, specifying the database connection to use for the model.

    ```php
    use Illuminate\Database\Eloquent\Attributes\Connection;

    #[Connection('analytics')]
    class PageView extends Model
    {
    }

    ```

Queue / Job Attributes
----------------------

Configure job behavior declaratively using attributes.

- `#[Tries]`Sets the maximum number of times a job should be attempted, replacing `$tries`.

    ```php
    use Illuminate\Queue\Attributes\Tries;

    #[Tries(3)]
    class ProcessPayment implements ShouldQueue
    {
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    }

    ```
- `#[Timeout]`Defines the job timeout in seconds, replacing `$timeout`.

    ```php
    use Illuminate\Queue\Attributes\Timeout;

    #[Timeout(120)]
    class GenerateReport implements ShouldQueue
    {
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    }

    ```
- `#[Backoff]`Configures the delay between retries, supporting both fixed and exponential backoff strategies, replacing `$backoff`.

    ```php
    use Illuminate\Queue\Attributes\Backoff;

    // Fixed backoff
    #[Backoff(30)]
    class SyncInventory implements ShouldQueue
    {
        // ...
    }

    // Exponential backoff
    #[Backoff([10, 30, 60])]
    class AnotherJob implements ShouldQueue
    {
        // ...
    }

    ```

This is just a glimpse of the new attribute-driven features in Laravel 13. As the framework evolves, expect more components to adopt this modern, declarative approach.

---

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Fphp-attributes-in-laravel-13-a-comprehensive-guide&text=PHP+Attributes+in+Laravel+13%3A+A+Comprehensive+Guide) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Fphp-attributes-in-laravel-13-a-comprehensive-guide) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Are PHP Attributes in Laravel 13 breaking changes?        No, the new PHP Attributes in Laravel 13 are optional. The traditional property-based syntax for Eloquent models and queue jobs remains fully supported. 

      Q02  What Eloquent model properties can be replaced by attributes in Laravel 13?        In Laravel 13, attributes can replace properties like `$fillable`, `$guarded`, `$hidden`, `$visible`, `$appends`, `$table`, `$primaryKey`, `$keyType`, `$incrementing`, `$timestamps`, `$dateFormat`, `$connection`, and `$touches`. 

      Q03  How do PHP Attributes improve Queue Job configuration in Laravel 13?        Laravel 13 allows configuring Queue Jobs using attributes like `#[Tries]`, `#[Timeout]`, and `#[Backoff]`, providing a more declarative and readable way to manage job retry logic and execution parameters. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://www.msaied.com/articles) 

 [ ![Laravel Overlapping Scheduled Tasks: The Production Problem Nobody Talks About](https://cdn.msaied.com/93/01KTTJBMWPGG4V0TG5B5B6GF9P.png) 

### Laravel Overlapping Scheduled Tasks: The Production Problem Nobody Talks About

Laravel scheduled tasks can silently overlap in production, causing duplicate jobs, race conditions, and faile...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 11 Jun 2026     18 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-overlapping-scheduled-tasks-the-production-problem-nobody-talks-about) [ ![Provision Laravel Cloud From the Stripe CLI](https://cdn.msaied.com/89/7691d1d607cc9d4cb22156215eead147.png) Laravel Stripe CLI Laravel Cloud 

### Provision Laravel Cloud From the Stripe CLI

Streamline your Laravel Cloud provisioning with the Stripe CLI. Spin up infrastructure, manage credentials, an...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 10 Jun 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/provision-laravel-cloud-from-the-stripe-cli) [ ![JSON Schema Deserialization in Laravel 13.14](https://cdn.msaied.com/87/ec9f2bc8c8c8ba6afb67a065a5e19943.png) Laravel PHP JSON Schema 

### JSON Schema Deserialization in Laravel 13.14

Laravel 13.14.0 introduces a new JSON Schema deserializer, enhancing type object reconstruction from arrays. T...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 9 Jun 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/json-schema-deserialization-in-laravel-1314) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

Explore

- [Home](https://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [Contact](https://www.msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
