PHP 8.3 Enums &amp; Readonly Properties in Laravel | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com) [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles  ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

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

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

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    PHP 8.3+ Typed Enums, Backed Casts, and Readonly Properties in Modern Laravel        On this page       1. [  Why Primitive Obsession Still Haunts Laravel Apps ](#why-primitive-obsession-still-haunts-laravel-apps)
2. [  Defining a Backed Enum with Behaviour ](#defining-a-backed-enum-with-behaviour)
3. [  Eloquent Enum Casting ](#eloquent-enum-casting)
4. [  Storing Enum Arrays with a Custom Cast ](#storing-enum-arrays-with-a-custom-cast)
5. [  Readonly Properties for Immutable Value Objects ](#readonly-properties-for-immutable-value-objects)
6. [  Enum-Aware Validation Rules ](#enum-aware-validation-rules)
7. [  Key Takeaways ](#key-takeaways)

  ![PHP 8.3+ Typed Enums, Backed Casts, and Readonly Properties in Modern Laravel](https://cdn.msaied.com/344/0e6a808cf916b40631d3d362a687baa8.png)

  #laravel   #php8.3   #enums   #eloquent   #domain-modeling  

 PHP 8.3+ Typed Enums, Backed Casts, and Readonly Properties in Modern Laravel 
===============================================================================

     2 Jul 2026      1 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   Why Primitive Obsession Still Haunts Laravel Apps  ](#why-primitive-obsession-still-haunts-laravel-apps)
2. [  02   Defining a Backed Enum with Behaviour  ](#defining-a-backed-enum-with-behaviour)
3. [  03   Eloquent Enum Casting  ](#eloquent-enum-casting)
4. [  04   Storing Enum Arrays with a Custom Cast  ](#storing-enum-arrays-with-a-custom-cast)
5. [  05   Readonly Properties for Immutable Value Objects  ](#readonly-properties-for-immutable-value-objects)
6. [  06   Enum-Aware Validation Rules  ](#enum-aware-validation-rules)
7. [  07   Key Takeaways  ](#key-takeaways)

 Why Primitive Obsession Still Haunts Laravel Apps
-------------------------------------------------

Most Laravel codebases pass raw strings and integers everywhere — `'active'`, `1`, `'usd'`. These primitives carry no type information, require defensive checks at every boundary, and make refactoring risky. PHP 8.1 introduced backed enums; PHP 8.3 tightened the type system further with typed class constants and improved readonly semantics. Laravel has had first-class enum casting since v9. Combining all three gives you domain models that are self-documenting and compiler-verified.

Defining a Backed Enum with Behaviour
-------------------------------------

Don't treat enums as dumb constants. Add methods and implement interfaces directly on the enum.

```php
