Indirect modification of overloaded property App\\User::$membership has no effect laravel code example
Example: Indirect modification of overloaded property has no effect laravel
Due to how accessing model attributes is implemented in Eloquent, when you
access $category->specifics, a magic __get() method is called that returns a
copy of that attributes value. Therefore, when you add an element to that copy,
you are just changing the copy, not the original attributes value. That's why
you're getting an error saying that whatever you're doing, it won't have any
effect.
If you want to add a new element to $category->specifics array, you need to
make sure that the magic __set() is used by accessing the attribute in a setter
manner, e.g.:
$category->specifics =
array_merge($category->specifics, $this->request->get('specifics'));