mardi 28 mars 2017

Content cannot be null laravel

I'm trying to submit a form and I got this error

QueryException in Connection.php line 647: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'content' cannot be null (SQL: insert into 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 be able to be 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 were 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'));
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire