Error guides

Add [x] to fillable property to allow mass assignment

Eloquent refused to fill a model from an array because the attribute is not mass assignable. Declare the fillable attributes and pass only validated input.

Message
Add [title] to fillable property to allow mass assignment on [App\Models\Post].
Exception
Illuminate\Database\Eloquent\MassAssignmentException

What it means

You passed an array to create, update, fill or new Post([...]), and Eloquent refused to copy one of its keys onto the model. The docs explain why the guard exists: without it, a visitor could send an extra field such as is_admin and, through create($request->all()), change a column you never meant to expose. Every model is protected this way by default.

Why it happens

Whether you get an exception or a silently dropped value depends on the model:

  • The model declares neither Fillable nor Guarded. Every attribute is guarded, and Eloquent throws on the first key: Add [title] to fillable property to allow mass assignment on [App\Models\Post]. This is the common case right after php artisan make:model.
  • The model declares Fillable, and the array holds a key that is not in it. By default that key is dropped without a word. Post::create(['title' => 't', 'user_id' => 1]) saves the post with user_id empty when the column is nullable. When it is NOT NULL, the insert fails with SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value, which hides the real cause.
  • Model::preventSilentlyDiscardingAttributes() is on, so the dropped key throws instead. With a Fillable list the message is worded differently: Add fillable property [user_id] to allow mass assignment on [App\Models\Post]. With a Guarded list it is the first wording again. Model::shouldBeStrict() turns this on too.

Setting an attribute directly, $post->user_id = $id, is not mass assignment and is never blocked. Neither is a query builder update, such as Post::whereKey($id)->update([...]).

How to fix it

List the attributes a request may set with the Fillable attribute:

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;

#[Fillable(['title', 'body'])]
class Post extends Model
{
}

A protected $fillable = ['title', 'body']; property works the same way.

Then fill the model from validated data only, and set the sensitive columns yourself:

$validated = $request->validate([
    'title' => ['required', 'string', 'max:255'],
    'body' => ['required', 'string'],
]);

$post = new Post($validated);
$post->user_id = $request->user()->id;
$post->save();

To see dropped attributes while you develop, make them throw outside production. The docs place this in the boot method of AppServiceProvider:

use Illuminate\Database\Eloquent\Model;

Model::preventSilentlyDiscardingAttributes(! $this->app->isProduction());

The docs also offer the Unguarded attribute, which makes every attribute fillable. Use it only when every array you pass to fill, create and update is one you built by hand.

Find it in production

With APP_DEBUG=false the visitor gets a 500 page titled "Server Error". Laravel reports MassAssignmentException, so it is written at error level to storage/logs/laravel.log, and Ranetrace's error monitoring records it with its stack trace and the request it happened on.

The silent case leaves nothing in any log, unless a NOT NULL column turns it into the 1364 error above. A form that saves but forgets one field, or a column that stays empty, is the sign: compare the keys you pass with the model's Fillable list.

Reproduced on Laravel 13.45, PHP 8.5, MySQL 8.0.27, 5 December 2026.

Start monitoring today

Websites go down and code throws errors. Ranetrace tells you when it happens to yours, why it matters and what to do next.

Start your 30-day free trial From $9 a month. No credit card required.