I am using Bootforms to edit posts on a blog
<?php $formOptions = [
'url' => 'user',
'sm' => [2, 5],
'lg' => [2, 5],
'method'=> 'put'
]; ?>
{!! BootForm::openHorizontal($formOptions)->action(route('news.update', $post)) !!}
<input type="hidden" name="_method" value="PUT">
{!! BootForm::text('Titre', $post->title) !!}
{!! BootForm::text('Slug', $post->slug) !!}
{!! BootForm::textarea('Contenu', $post->content) !!}
{!! BootForm::submit('Editer') !!}
{!! BootForm::close() !!}
Here is my PostController function once I update my post :
public function update($id, Request $request)
{
$post = Post::findorFail($id);
$title = $request->input('title');
$post->title = $title;
$post->content = $request->input('Contenu');
$request->has('save');
$post->save();
return redirect(route('news.index'));
}
But once I edit my post, I encouter this error like i am sending empty strings : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null (SQL: update posts
set title
= , content
= , updated_at
= 2016-12-14 20:48:25 where id
= 3)
If you see where is the problem, I could use some help ...