Closed thewebartisan7 closed 2 years ago
Same issue happen with code below:
if (array_key_exists($key, parent::getAttributes())) {
parent::setAttribute($key, $value);
return;
}
line 382
And could be solved in the same way:
if(in_array($key, parent::getFillable()) && !in_array($key, parent::getGuarded())) {
parent::setAttribute($key, $value);
return;
}
I am also not yet sure why this two similar check it's done.
I mean if attributes is checked here, and is found, not need to check if exist in database table that column. If Eloquent don't find it, it should not exists, I think?
Hello, can you please send a PR request and ill merge this in?
Below code in __set() method apart that make a query for each field when you create a new model, make fillable also guarded and not fillable attributes of the model:
I am not yet sure if below solution could be better for avoid this security break, since you can't anymore use something like:
User::create($request->all())
since also not fillable and guarded attributes are set.
This is proposed solution:
or even better:
What do you think?