При попытке изменить сообщение в блоге в приложении laravel 5.7 получаю вышеуказанную ошибку.Любые идеи о том, как решить эту проблему?
My Post Controller;
public function edit($id)
{
$post = Post::find($id);
return view('posts.edit')->withPost($post);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Form validation
$this->validate($request, array(
'title' =>'required|max:190',
'category' =>'required|max:190',
'body' =>'required'
));
//save in db
$post = Post::find($id);
$post->title=$request->input('title');
$post->category=$request->input('category');
$post->body=Purifier::clean($request->input('body'));
$post->save();
Session::flash('success','Blog successfuly updated!');
return redirect()->route('posts.show',$post->id);
}
My AuthServiceProvider;
public function registerPostPolicies()
{
Gate::define('create-post', function($user){
$user->hasAccess(['create-post']);
});
Gate::define('update-post', function($user, Post $post){
$user->hasAccess(['update-post']) or $user ->id ==$post -> user_id;
});
Gate::define('delete-post', function($user, Post $post){
$user->hasAccess(['delete-post']) or $user ->id ==$post -> user_id;
});
}
Я потратил несколько часов, пытаясь решить эту проблему,но я, кажется, не делаю никакого прогресса.
Любая помощь будет высоко ценится