I have a hard time understanding the basic attribute casting in Laravel.
I want to store some coordinates in my database:
$coordinates = [ 'x' => 100, 'y' => 60, 'h' => 250, 'w' => 250, ];
To save the coordinates, I do this:
$field = StreamField::find(4); $field->coordinates = $coordinates; $field->save();
I have declared belows
casts on my
protected $casts = [ 'coordinates' => 'array' ];
In my migration, the
coordinates column is created like this:
Now is this the correct way of doing it?