Laravel 13 PHP Attributes: Eloquent, Queues &amp; More | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. PHP Attributes in Laravel 13: A Comprehensive Guide

   [Laravel](https://www.msaied.com/public/articles?category=laravel) 

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

 Explore the new PHP Attributes in Laravel 13, transforming Eloquent models, queue jobs, and more. Learn how to leverage these declarative features with practical examples.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 18 Mar 2026 · Updated 12 Jun 2026 · 3 min read

ShareCopy linkCopied

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

  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)

 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.

---

- [Laravel](https://www.msaied.com/public/articles?search=Laravel)
- [PHP](https://www.msaied.com/public/articles?search=PHP)
- [Attributes](https://www.msaied.com/public/articles?search=Attributes)
- [Eloquent](https://www.msaied.com/public/articles?search=Eloquent)
- [Queues](https://www.msaied.com/public/articles?search=Queues)

 Frequently asked questions 
---------------------------

  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.

   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`.

   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.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

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

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleLaravel 13: Release Date and Key New Features Announced at Laracon EU](https://www.msaied.com/public/articles/laravel-13-release-date-and-key-new-features-announced-at-laracon-eu) [Next articleIs The New Laravel 13 Teams The Same As "Multi-Tenancy"?](https://www.msaied.com/public/articles/is-the-new-laravel-13-teams-the-same-as-multi-tenancy)  

   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)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
