I have been using mass assignment a lot. I recently came across this issue, where I create fillable, and also defaults for null values, but on using mass assignment, if my inputs are empty, it returns a "Cannot Be Null" Error.
My Model
protected $fillable = ['name','status'];
My Controller
$this->model->create($request->all());
My Migration
$table->boolean('status')->default(0);
Shouldn't the above mean that when I provide nothing on the input field status
, it should default to 0? But column can't be null
is thrown.
Is there any solution to this?