Answers for "casts in model laravel"

PHP
1

casts in model laravel

Once the cast is defined, you may access
  the options attribute and 
  it will automatically be deserialized 
  from JSON into a PHP array. When you set 
  the value of the options attribute, the given 
  array will automatically be serialized back into 
  JSON for storage:


use App\Models\User;

$user = User::find(1);

$options = $user->options;

$options['key'] = 'value';

$user->options = $options;

$user->save();
Posted by: Guest on June-12-2021

Browse Popular Code Answers by Language