Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 3 months ago.
0

Input::all() will get all input in form not fillable

0

Thanks iridion9.

As he said this is now automatically added out of the box, then after watching this video do you only need to assign $fillable if it is throwing an mass assignment exception error?

Last updated 7 years ago.
0

Mass assignment is enabled out of the box. If you plan on setting multiple fields through your application you need to set either the $fillable or $guarded value in your Model. For instance if you are allowing users to join your site your probably have a form with multiple input fields. Since you will be taking the data and storing it to your database, these fields must be $fillable. Keep in mind the values or fields that you have in your form input are likely not ALL the fields on your table. So a typical user table has an id field and timestamps which is never set directly by the ui.

0

Fillable only really applies to mass assignment and that is only comes into play when you are creating/updating an Eloquent model. Reading your question it does not apply to requesting attributes. Some examples where using fillable is advised:

// Here we are creating a new article instance and just want to pass the fields from the input array
$article = new Article(Input::all());
$article->save();

// Here we are creating the article and persisting it
$article = Article::create(Input::all());

The docs are also nice and clear.

0

I found a Laracast here that Jefferey explains this quite well

[https://laracasts.com/series/laravel-5-fundamentals/episodes/8]

0

now before posting any data from form to the live to the database you should specify in the laravel model that the columns name you can fill by the post data for e.g protected $fillable = ['title', 'description', 'status','user_id','accepted'];

0

Sign in to participate in this thread!

LoadForge

Your banner here too?

ottz0 ottz0 ottz0 Joined 15 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.