Content cannot be null laravel -
i'm trying submit form , got error
queryexception in connection.php line 647: sqlstate[23000]: integrity constraint violation: 1048 column 'content' cannot null (sql: insert
content
(title
,content
,image
,updated_at
,created_at
) values (home, , [], 2017-03-28 11:10:58, 2017-03-28 11:10:58))
the content should able null.
my migration table
schema::create('content', function(blueprint $table) { $table->increments('id'); $table->string('title'); $table->text('content'); $table->string('image'); $table->timestamps(); });
my store method
public function store() { $input = input::all(); $validation = validator::make($input, content::$rules); if($validation->fails()){ return redirect()->route('content.create') ->withinput() ->witherrors($validation) ->with('message', 'there validation errors'); } if($validation->passes()){ $content = new content(); $menuid = (array) array_get($input, 'menu_id'); $content->fill($input)->save(); $content->menu()->sync($menuid); $content = content::all(); return view('content::admin.index', compact('content')); } }
schema::create('content', function(blueprint $table) { $table->increments('id'); $table->string('title')->nullable(); $table->text('content'); $table->string('image'); $table->timestamps(); });
just add nullable on column can null
Comments
Post a Comment