📜  抛出 403 laravel - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:53.790000             🧑  作者: Mango

代码示例1
// if post isn't found by $id, show 404
$post = Post::findOrFail($id);

// if user isn't owner of post, show 403
if (!Auth::user() || Auth::user()->id != $post->user_id) {
    abort(403);
}

return view('post-edit',compact('post'));