laravel model to array code example
Example 1: laravel object to array
function objectToArray(&$object)
{
return @json_decode(json_encode($object), true);
}
Example 2: laravel json eloquent
protected $casts = [
'birthday' => 'date:Y-m-d',
'joined_at' => 'datetime:Y-m-d H:00',
];