title: Laravel 5.1 protecting routes with ownership using middleware
body: <p>I'm trying to learn Laravel, but don't quite understand how i can accomplish my task the best way.</p>
  
  <p>Scenario,</p>
  
  <p>A user (user_id 5) may create a todo list, with the id of 3 (todo_id 3). Each of them live in their own model, so users model, and todo model. I'm currently checking if they created the todo by passing this into the method,</p>
  
  <pre><code>public function show($id)
  {
      TodoList::where('id',$id)-&gt;where('user_id', auth::id())-&gt;firstOrFail();
      return 'ok';
  }
  </code></pre>
  
  <p>So, i was thinking it would be possible to filter all this, using middleware. I have more models that requires the same action, so user 2, can't change/edit the todo_list for user 5 etc. And this needs to be attached to all methods, to block their access. Show, View, Delete etc.</p>
  
  <p>Is there any way of doing this, so i don't have to create a new middleware for each model?</p>