A recent security release for Laravel has put in an extra constraint that you can only mass assign to existing columns in the table, which has broken some of my models where I've used camelCasing, since the column check happens before the attribute is set (and written to the database).
It is possible to overload the Eloquent isGuardableColumn method so that it looks for the snake_cased field name instead. I propose adding the following to the CamelCasing behaviour:
/**
* Overloads the eloquent isGuardableColumn method to ensure that we are checking for the existence of
* the snake_cased column name.
*
* @param string $key
* @return bool
*/
protected function isGuardableColumn($key)
{
return parent::isGuardableColumn($this->getSnakeKey($key));
}
I'm happy to do a PR for this - I've already confirmed it doesn't break any existing tests.
A recent security release for Laravel has put in an extra constraint that you can only mass assign to existing columns in the table, which has broken some of my models where I've used camelCasing, since the column check happens before the attribute is set (and written to the database).
It is possible to overload the Eloquent
isGuardableColumn
method so that it looks for the snake_cased field name instead. I propose adding the following to the CamelCasing behaviour:I'm happy to do a PR for this - I've already confirmed it doesn't break any existing tests.