title: Permissions User and Roles
body: <p>I need some advice, basically I have an application where users can register as normal customers, and inside the dashboard there is a option to register as an author for a list of categories. A customer can be many authors.</p>
  
  <p>So basically after registering/subscribing as an author in the custom dashboard appears a box of his author(s) that he created and after clicking it goes to a specific dashboard with different menu, etc.</p>
  
  <p>My only issue is when I start to create the permissions, for example I created a Middle-ware with the name of "author", so when someone try to access these pages it must be an author.</p>
  
  <p>Middleware code:</p>
  
  <pre><code>public function handle($request, Closure $next)
      {
  
          if(isset($request-&gt;id) &amp;&amp; auth()-&gt;check() &amp;&amp; count(auth()-&gt;user()-&gt;authorsProfile) &gt; 0){
              return $next($request);
          }
          return redirect('/dashboard')-&gt;with("error","Only Authors Allowed");
      }
  </code></pre>
  
  <p>example:</p>
  
  <pre><code>Route::group(['middleware' =&gt; ['auth','author']], function() {
  //Dashboard
  Route::get('authorsarea/{id}','AuthorController@dashboard')-&gt;name('author-dashboard');
  });
  </code></pre>
  
  <p>So the second validation i need to make is inside the controllers, I need to check based on the ID if this an author id belongs to the customer/user.</p>
  
  <p>example:</p>
  
  <pre><code> public function dashboard($id)
      {
  
          $user = Auth::user();
  
          $user_author = Author::find($id);
  
          if($user_author-&gt;user_id != Auth::user()-&gt;id){
              return back()-&gt;with("error","This Author is not you");
          }
  
          //Go to dashboard
          return view('frontend.author.dashboard');
      }
  </code></pre>
  
  <p>I feel that pasting alwasy this code and checking if this author belongs to the user doesnt feel quite clean, is there a better way than pasting always this code in each page controller where I try to access a private area for authors?</p>
  
  <p>Or even if you guys feel that there is a completely different way of doing all of this I'm open to it.</p>