Fill assigment model with not fillable column #40366
Unanswered
jamesRUS52
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, all!
Now, when trying to mass assigment with column not in fillable list, we get ignored value, but it save silently with default database value. It's not clearly at all and may make logical errors with data.
E.g.
$filable = ['column1'];
database schema like
create table tab column1 int, column2 int default 0;
TabModel::create(['column1'=>1, 'column2'=>1]);
The record in database will be column1 = 1 coumn2 = 0
and no any error has occured. Its not clear at all. The developer should every time check fillable in model.
My suggest is to chenge $this->totallyGuarded() check to throw Exception if fillable list fill or not in
public function fill(array $attributes)
{
$totallyGuarded = $this->totallyGuarded();
`
What do you think about it?
Beta Was this translation helpful? Give feedback.
All reactions