Answers for "laravel casts date format"

PHP
5

laravel blade date format

//laravel method 1
{{ $data->created_at->isoFormat('dddd D') }}

//laravel method 2 
{!! date('d/M/y', strtotime($data->created_at)) !!}
Posted by: Guest on August-08-2020
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