<?php
namespace AppModels;
use IlluminateDatabaseEloquentModel;
class User extends Model
{
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'options' => 'array',
];
}
/* array
AsStringable::class
boolean
collection
date
datetime
immutable_date
immutable_datetime
decimal:<digits>
double
encrypted
encrypted:array
encrypted:collection
encrypted:object
float
integer
object
real
string
timestamp */
class Project extends Model
{
// ...
protected $casts = [
'config' => 'array',
];
// ...
}
<?php
use IlluminateDatabaseEloquentCastsAsCollection;
protected $casts = [
'options' => AsCollection::class,
];