Only the post author will be able to edit the post
public function edit($id)
{
    $post = POST::find($id);

    // Check for correct user
    if (auth()->user()->id !== $post->user_id) {
        return redirect('/posts')->with('error', 'Unauthorized page');
    }

    return view('posts.edit')->with('post', $post);
}
by Valeri Tandilashvili
4 years ago
Laravel
auth
Laravel From Scratch
0
Pro tip: use ```triple backticks around text``` to write in code fences