-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Closed
Copy link
Description
- Laravel Version:
5.5.2 - PHP Version:
PHP 7.1.3 (cli) (built: Apr 4 2017 18:40:27) ( NTS ) - Database Driver & Version:
10.1.19-MariaDB
Description:
When using Model::create, if a non-fillable field is used, an error is returned.
The standard HTML output tells it is a MassAssignmentException which is quite explicit.
However when expecting a JSON response, the error output is unclear. It looks like that:
{
"message": "title",
"file": "/Users/rgehan/Sites/laravel-preset-react/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php",
"line": 237,
"trace": [
{
"file": "/Users/rgehan/Sites/laravel-preset-react/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php",
"line": 157,
"function": "fill",
"class": "Illuminate\\Database\\Eloquent\\Model",
"type": "->",
"args": [
{
"title": "This is the title",
"content": "Etiam natoque fusce dis euismod dolor condimentum egestas parturient fermentum, sociis habitasse libero nam adipiscing cubilia scelerisque enim dignissim pulvinar, aliquam ad convallis in mollis quisque proin praesent."
}
]
},
{
"file": "/Users/rgehan/Sites/laravel-preset-react/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php",
"line": 280,
"function": "__construct",
"class": "Illuminate\\Database\\Eloquent\\Model",
"type": "->",
"args": [
{
"title": "This is the title",
"content": "Etiam natoque fusce dis euismod dolor condimentum egestas parturient fermentum, sociis habitasse libero nam adipiscing cubilia scelerisque enim dignissim pulvinar, aliquam ad convallis in mollis quisque proin praesent."
}
]
},
...Nothing say in this error that it is a MassAssignmentException. The titlefield of the output is simply the field that is not fillable.
Steps To Reproduce:
- Create a model with a field that is not fillable
- Attempts to
Model::create(['not_fillable_field' => 'abc', ...]);from a request with the header:Accept: application/json
paulofreitas
Metadata
Metadata
Assignees
Labels
No labels