Answers for "Indirect modification of overloaded property has no effect laravel"

PHP
0

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'));
Posted by: Guest on April-06-2021

Code answers related to "Indirect modification of overloaded property has no effect laravel"

Browse Popular Code Answers by Language