Answers for "throw 403 laravel"

PHP
0

throw 403 laravel

// 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'));
Posted by: Guest on October-28-2021

Browse Popular Code Answers by Language