0
0
Laravelframework~10 mins

Mass assignment protection in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to allow mass assignment for the 'name' attribute in a Laravel model.

Laravel
protected $fillable = ['[1]'];
Drag options to blanks, or click blank then click option'
Aemail
Bpassword
Cid
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Putting attributes not intended for mass assignment like 'password' or 'id' in $fillable.
Leaving $fillable empty and expecting mass assignment to work.
2fill in blank
medium

Complete the code to protect all attributes from mass assignment in a Laravel model.

Laravel
protected $guarded = ['[1]'];
Drag options to blanks, or click blank then click option'
Apassword
B*
Cemail
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using $fillable instead of $guarded to block all attributes.
Listing specific attributes instead of '*' to block all.
3fill in blank
hard

Fix the error in the model to allow mass assignment only for 'title' and 'content'.

Laravel
protected $fillable = ['title', '[1]'];
Drag options to blanks, or click blank then click option'
Aauthor
Bdate
Ccontent
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Adding attributes not intended for mass assignment.
Leaving out 'content' from the fillable array.
4fill in blank
hard

Fill both blanks to define a model that blocks mass assignment on all attributes except 'email'.

Laravel
protected $guarded = ['[1]'];
protected $fillable = ['[2]'];
Drag options to blanks, or click blank then click option'
A*
Bemail
Cusername
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using $fillable without $guarded to block attributes.
Not listing allowed attributes in $fillable.
5fill in blank
hard

Fill all three blanks to create a mass assignment safe model that allows 'name' and 'email' but blocks 'password'.

Laravel
protected $fillable = ['[1]', '[2]'];
protected $guarded = ['[3]'];
Drag options to blanks, or click blank then click option'
Aname
Bemail
Cpassword
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Putting 'password' in $fillable by mistake.
Leaving $guarded empty and exposing sensitive data.