Hi,
on a model I have a field 'home_filtering_settings' which is used in a $cast as:
protected $casts = [
'email_verified_at' => 'datetime',
'home_filtering_settings' => AsArrayObject::class,
];
For some reason, it will not work if the initial value in the db is empty.
Here is how I use it:
$currentUser->home_filtering_settings[ 'category-setting' ] = $categorySelectedId;
For this to work I must manually set in the db the content of home_filtering_settings to [].
But if I try to set this default value from migration:
$table->json('home_filtering_settings')->default('[]');
it will crash with: SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB, TEXT, GEOMETRY or JSON column 'home_filtering_settings' can't have a default value
My questions are:
- What is the appropriate default value for home_filtering_settings ?
- How to set it from migration?