close

[Solved] Laravel 5.4 field doesn’t have a default value

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Laravel 5.4 field doesn’t have a default value in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Laravel 5.4 field doesn’t have a default value Error Occurs?

Today I get the following error Laravel 5.4 field doesn’t have a default value in php.

How To Solve Laravel 5.4 field doesn’t have a default value Error ?

  1. How To Solve Laravel 5.4 field doesn't have a default value Error ?

    To Solve Laravel 5.4 field doesn't have a default value Error Remove the guarded array and add the fillable instead:
    protected $fillable = ['user_id', 'deal_id'];

  2. Laravel 5.4 field doesn't have a default value

    To Solve Laravel 5.4 field doesn't have a default value Error Remove the guarded array and add the fillable instead:
    protected $fillable = ['user_id', 'deal_id'];

Solution 1

I am using Laravel 8 and fixed this error thorugh this two steps:

  1. move the word from $guarded array to $fillable array in User Mode
  2. Config.database.php: 'strict' => false in the array of 'mysql'

Solution 2

Remove the guarded array and add the fillable instead:

protected $fillable = ['user_id', 'deal_id'];

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment