Enum casting is only available for PHP 8.1+.Eloquent also allows you to cast your attribute values to PHP Enums. To accomplish this, you may specify the attribute and enum you wish to cast in your model's $casts property array:use App\Enums\ServerStatus; /** * The attributes that ...
class AsEnumCollection implements Castable (View source) Propertiesprotected $arguments Methodsstatic castUsing(array $arguments) Get the caster class to use when casting from / to this cast target. __construct(array $arguments) No description get($model, $key, $value, $attributes) No ...
Enum CastingEloquent also allows you to cast your attribute values to PHP Enums. To accomplish this, you may specify the attribute and enum you wish to cast in your model's casts method:use App\Enums\ServerStatus; /** * Get the attributes that should be cast. * * @return array<...
[ {$table->json('field_name')->nullable()->after('some_field'); }); ...
Enum casting was contributed byMohamed Said. Eloquent now allows you to cast your attribute values to PHP"backed" enums. To accomplish this, you may specify the attribute and enum you wish to cast in your model's$castsproperty array: ...
Adds enum casting to Request (#43239) #Revert Revert"Fix default parameter bug in routes"(#43208) Revert route change PR (#43255) #Fixed Fix transaction attempts counter for sqlsrv (#43176) #Changed Make assertDatabaseHas failureDescription more multibyte character friendly (#43181) ...
- Adds enum casting to Request ([#43239](https://github.com/laravel/framework/pull/43239)) ### Revert - Revert ["Fix default parameter bug in routes"](https://github.com/laravel/framework/pull/42942) ([#43208](https://github.com/laravel/framework/pull/43208)) ...
The Laravel team released 9.49 this week with support for casting an array of enums, CLI prompts, and more. Be sure the check out the changelog as this week's release is chock full of new additions, fixes, and changes from the last two weeks; most of the Laravel team was at Laracon...