Laravel Mass Assignment, Guarded or Fillable?

Kshitij Soni
Dec 2, 2017 · 2 min read
class Student extends Model {protected $fillable = [‘first_name’, ‘last_name’, ‘email’]; //← only the field names inside the array can be mass-assign}
class Student extends Model {
protected $guarded = [‘id’, ‘student_type’]; //← the field name inside the array is not mass-assignable
}
protected $guarded = [‘*’];

Kshitij Soni

Written by

Developer by profession . Youtube channel : https://www.youtube.com/channel/UCOWT2JvRnSMVSboxvccZBFQ

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade