Skip to main content
Laravel Bug Hunt Medium +20 XP

Mass Assignment Blocked

Model fails to save with fillable error.

LaravelFind the bug
1class User extends Model {
2 // No $fillable or $guarded defined
3}
4User::create(['name' => 'Alice', 'email' => 'a@b.com']);
The bug is on line 2

Select the correct fix

Show answer and explanation

Answer: Both A and C work

Laravel blocks mass assignment by default. Define $fillable with allowed fields, or $guarded = [] to allow all fields.

Hint: Mass assignment protection requires $fillable or $guarded.

What this challenge tests

Bug Hunt in Laravel: mass-assignment, security, eloquent.

Related challenges