【发布时间】:2016-11-05 00:40:49
【问题描述】:
当我尝试通过单击删除按钮将删除功能添加到帖子时出现此错误。 我哪里做错了?
在 PostController 中删除 post 函数:
public function getDeletePost($post_id)
{
$post =Post::where('id',$post_id)->first();
$post->delete();
return redirect()->route('dashboard')->with(['message'=> 'Successfully deleted!!']);
}
【问题讨论】:
-
我现在在手机里,我建议直接删除而不是先删除,因为就我现在首先返回一个数组...
-
方法
first()返回Model|Builder|null(laravel.com/api/5.3/Illuminate/Database/Eloquent/…) -
好的,谢谢...@Joanquin Javi。我去看看。
-
好的...我会检查一下...@Marek Skiba。谢谢。
标签: laravel