title: Laravel 5 determine if current user has permission to update a post
body: <p>I am following <a href="https://laracasts.com/series/laravel-5-fundamentals/episodes/14" rel="nofollow">jeffreys laravel fundamental series</a> and I'm stuck at some point. </p>
  
  <p>How can I ensure that the current user can only edit/update his own article?</p>
  
  <p>I have the feeling that I have to focus on my <code>ArticleRequest</code> class, but no idea what to tell laravel to do inside <code>authorize()</code>.</p>
  
  <p>My ArticlesController:</p>
  
  <pre><code>&lt;?php
  namespace App\Http\Controllers;
  
  use App\Article;
  use Carbon\Carbon;
  use App\Http\Requests\ArticleRequest;
  use App\Http\Requests;
  use Illuminate\Http\Request;
  use Auth;
  
  class ArticlesController extends Controller
  {
  
  public function __construct() {
    $this-&gt;middleware('auth');
  }
  
  
  public function index() {
  
    $articles = Article::latest('published_at')-&gt;published()-&gt;get();
    return view('articles.index')-&gt;withArticles($articles);
  }
  
  public function show($id) {
  
    $article = Article::findOrFail($id);
    //dd($article-&gt;created_at-&gt;diffForHumans());
    return view('articles.show')-&gt;withArticle($article);
  }
  
  public function create() {
  
    return view('articles.create');
  }
  
  
  public function store(ArticleRequest $request) {
  
    //Create new article witj the attributes from the form
    $article = new Article($request-&gt;all());
    //Get the authenticated users articles and save a new one (with passed trough $article object)
    Auth::user()-&gt;articles()-&gt;save($article);
  
    return redirect('articles');
  }
  
  public function edit($id) {
  
    $article = Article::findOrFail($id);
    return view('articles.edit')-&gt;withArticle($article);
  }
  
  
  public function update($id, ArticleRequest $request) {
  
    $article = Article::findOrFail($id);
    $article-&gt;update($request-&gt;all());
    return redirect('articles');
  
   }
  }
  </code></pre>
  
  <p>ArticleRequest:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Requests;
  
  use App\Http\Requests\Request;
  
  class ArticleRequest extends Request
  {
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
  
  
          return true;
      }
  
      /**
       * Get the validation rules that apply to the request.
       *
       * @return array
       */
      public function rules()
      {
  
          return [
              'title' =&gt; 'required',
              'body' =&gt; 'required',
              'published_at' =&gt; 'required|date'
          ];
      }
  }
  </code></pre>
  
  <p>My ArticlesTabel Schema:</p>
  
  <pre><code>Schema::create('articles', function (Blueprint $table) {
            $table-&gt;increments('id');
            $table-&gt;integer('user_id')-&gt;unsigned();
            $table-&gt;string('title');
            $table-&gt;text('body');
            $table-&gt;timestamp('created_at');
            $table-&gt;timestamp('published_at');
  
            $table-&gt;foreign('user_id')
                  -&gt;references('id')
                  -&gt;on('users')
                  -&gt;onDelete('cascade');
  
        });
  </code></pre>