{"record":{"id":"9bc7253a285b8365","repo":"laravel/framework","slug":"add-fillable-property-s-to-allow-mass-assignmen","errorCode":null,"errorMessage":"Add fillable property [%s] to allow mass assignment on [%s].","messagePattern":"Add fillable property \\[(.+?)\\] to allow mass assignment on \\[(.+?)\\]\\.","errorType":"exception","errorClass":"MassAssignmentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Eloquent/Model.php","lineNumber":708,"sourceCode":"                if (isset(static::$discardedAttributeViolationCallback)) {\n                    call_user_func(static::$discardedAttributeViolationCallback, $this, [$key]);\n                } else {\n                    throw new MassAssignmentException(sprintf(\n                        'Add [%s] to fillable property to allow mass assignment on [%s].',\n                        $key, get_class($this)\n                    ));\n                }\n            }\n        }\n\n        if (count($attributes) !== count($fillable) &&\n            static::preventsSilentlyDiscardingAttributes()) {\n            $keys = array_diff(array_keys($attributes), array_keys($fillable));\n\n            if (isset(static::$discardedAttributeViolationCallback)) {\n                call_user_func(static::$discardedAttributeViolationCallback, $this, $keys);\n            } else {\n                throw new MassAssignmentException(sprintf(\n                    'Add fillable property [%s] to allow mass assignment on [%s].',\n                    implode(', ', $keys),\n                    get_class($this)\n                ));\n            }\n        }\n\n        return $this;\n    }\n\n    /**\n     * Fill the model with an array of attributes. Force mass assignment.\n     *\n     * @param  array<string, mixed>  $attributes\n     * @return $this\n     */\n    public function forceFill(array $attributes)\n    {","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Eloquent/Model.php#L690-L726","documentation":"Thrown by the tail of fill() when the number of keys passed does not match the keys fillableFromArray() returned, AND Model::preventsSilentlyDiscardingAttributes() is enabled. Unlike the per-key check, this fires for keys that were never even considered (entirely outside the fillable set) and reports all of them at once. It only fires in strict mode; with default settings those keys are silently ignored.","triggerScenarios":"Model::preventSilentlyDiscardingAttributes() has been called (typically in AppServiceProvider boot), then Model::fill([...]) / ::create([...]) is called with one or more keys that are not in $fillable.","commonSituations":"Strict mode turned on across the app to surface dropped fields; a FormRequest returning extra keys the model does not whitelist; renaming a DB column but not the request payload; hidden/extra input fields in tests.","solutions":["Add every reported key to the model's $fillable array.","Strip non-fillable keys from the input before calling fill (e.g. only($fillableKeys)).","Use forceFill() when you intentionally want to bypass the guard for those keys.","If the discard is intentional, disable preventSilentlyDiscardingAttributes() for that flow."],"exampleFix":"// before\nModel::preventSilentlyDiscardingAttributes();\n$user->fill(['name' => 'A', 'legacy_col' => 1]); // 'legacy_col' not fillable\n\n// after - whitelist or strip\n$user->fill(collect(request()->all())->only((new User)->getFillable())->toArray());","handlingStrategy":"validation","validationCode":"// Strip anything not fillable before fill() so strict mode never trips\n$fillable = (new $modelClass)->getFillable();\n$model->fill(collect($input)->only($fillable)->toArray());","typeGuard":"function allKeysFillable(\\Illuminate\\Database\\Eloquent\\Model $model, array $input): bool {\n    return empty(array_diff(array_keys($input), $fillable = $model->getFillable()));\n}","tryCatchPattern":"try {\n    $model->fill($input);\n} catch (\\Illuminate\\Database\\Eloquent\\MassAssignmentException $e) {\n    if (str_contains($e->getMessage(), 'Add fillable property')) {\n        // parse keys from message, report; or fall back to only()\n        $model->fill(collect($input)->only($model->getFillable())->toArray());\n    } else { throw $e; }\n}","preventionTips":["Enable Model::preventSilentlyDiscardingAttributes() in tests/staging to catch dropped fields before production.","Filter request input with only($model->getFillable()) in form requests or controllers.","Review $fillable whenever you rename or add a DB column."],"tags":["eloquent","mass-assignment","fillable","strict-mode","validation"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}