I want to add multiple values to a names column in my database. I've set the casts in the model to make this an array.
Controller
public function add() {
$id = 1;
$db = Article::find($id)->first();
$start = $db->names;
$db->names = array_push($db->names,'value');
}
Model
class Article extends Model
{
protected $casts = [
'names' => 'array'
];
}
This gives me an error message back
Indirect modification of overloaded property App\Article::$names has no effect
How do I push (or remove) a value to the array in my database?