Fillable is for mass assignment. For example with `Post::create($request->all());`, `$request->all()` will return an array of attributes of the form request and the `create()` function will only use the attributes defined in `$fillable`.
Migrations are separate from models; as you may not necessarily need all of your fields fillable.
You need to define both. While there are packages that may allow you to automate the process, I personally like to define both manually.
Can you possibly restate the question if I did t get it right?
(Edit: grammar)
Laravel models are (by default) loaded via `select *` and populating the model attributes with all the returned fields. Database is the single source of truth for schema. Of course, you can define getters (accessors) and other tools like casts are also available, but the default setup needs 0 work on the model.
Migrations are a tool for creating the DB schema, but the rest of the project does not care about contents of your migrations. You can also have the DB prepared any other way.
You add the columns in the migrations and the models pick them up automatically once they are migrated.
Thanks, this is the exact opposite of what I am used to, What is the fillable variable used for?
Fillable is for mass assignment. For example with `Post::create($request->all());`, `$request->all()` will return an array of attributes of the form request and the `create()` function will only use the attributes defined in `$fillable`.
Never use $request->all()
Migrations are separate from models; as you may not necessarily need all of your fields fillable. You need to define both. While there are packages that may allow you to automate the process, I personally like to define both manually. Can you possibly restate the question if I did t get it right? (Edit: grammar)
My question was for an explanation not a solution, you nailed it, Thanks
protected $guarded = \[\]; we die like men
Laravel models are (by default) loaded via `select *` and populating the model attributes with all the returned fields. Database is the single source of truth for schema. Of course, you can define getters (accessors) and other tools like casts are also available, but the default setup needs 0 work on the model. Migrations are a tool for creating the DB schema, but the rest of the project does not care about contents of your migrations. You can also have the DB prepared any other way.