Recently I came to know about this when I was trying to insert data into database. When I inserted the data I got error that mass assignable is not allowed
.
What is mass assignable ?
When you try to insert more than one field of data in your database table then it becomes mass(more than one) assignable. If you like to create/edit more than one field in the table your need to mention that in Model.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
//
protected $fillable = [
'title', 'content', 'category',
];
}
Now we can insert or modify all these fields at once.
If you don’t specify fields as fillable then you need to use forceCreate
. It force the laravel to ignore the model fillable and force to insert the data in the database.