Support the ongoing development of Laravel.io →
posted 6 years ago
Laravel

the error :SQLSTATE[HY000]: General error: 1364 Field 'description' doesn't have a default value (SQL: insert into projects (title, updated_at, created_at) values (projet 5, 2019-03-01 22:13:19, 2019-03-01 22:13:19))

class ProjectController.php

public function create()
   {
        return view('projects.create');
   }
   public function store()
   {
       //dd(request()->all());
       Project::create(request(['title','description']));
       return redirect('/projects');
   }

class Project.php

class Project extends Model
{
  protected $fillable=[
     'title','description'
   ];
}

web.php

Route::resource('projects','ProjectsController');
Last updated 2 years ago.
0

Field 'description' doesn't have a default value

you should probabaly make that column nullable

https://laravel.com/docs/5.8/migrations#column-modifiers

Last updated 6 years ago.
0

Either make the description column nullable (default null or empty string) or $description = request()->get('description','fallbackVal');

0

Make the field nullable in MySQL

0

@Cameron thanks it works

0

Glad it’s working

0

Sign in to participate in this thread!

Eventy

Your banner here too?

yosra yosrabettaieb Joined 1 Feb 2018

Moderators

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

Your logo here?

Laravel.io

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

© 2025 Laravel.io - All rights reserved.