Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Laravel 5.0 Difference between Fillable and Guarded

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 978
    Comment on it

    Hi Readers,


    If you are new to Laravel you will definitely come across two properties in the model one is Fillable and another one is Guarded. I myself did not get the use of these properties but once I get along I understood the actual use of these properties. Both these properties can be set at the class or instance level


    1) Fillable property:- This property specifies which attributes in the table should be *mass-assignable.

    protected $fillable = ['first_name', 'last_name', 'email'];
    

    2) Guarded property:- This property is inverse of fillable and hence do not allow *mass-assignable. The use of this property is to protect the attributes from being mass-assignment.

    protected $guarded = ['id', 'password'];
    

    *Mass assignment is a feature allows us to create a record from the values directly.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: