I want to give access to the edit page only to the authors of the posts.

`PostController`:

```
public function edit(Vocabulary $vocabulary)
{
    if ($vocabulary->user_id != Auth::id()) {
        return redirect()
            ->route('home')
            ->with('danger', 'You cannot edit another user's vocabulary.');
    }

    // return view...
}

```

---

So, my question is **how to compact this part of the code**. Can I use fewer code lines for this *(because I must write such blocks in lots of methods)*?

```
// I'm checking current User's id and author's id in the post..
if ($vocabulary->user_id != Auth::id()) { 
    return redirect()
        ->route('home')
        ->with('danger', "You cannot edit another user's vocabulary.");
}

```