Laravel: call global function for only authenticated users
<p>I want to call a global function for only authenticated users to check if their account has been verified. <strong>From all routes</strong> </p>

<p>Function.</p>

<pre><code>public function verifyAccount()
{
   if (Auth::user()-&gt;verified == 0)
   {
      return redirect('/checkpoint');
   }
   return redirect('/home');
}
</code></pre>

<p>And that function is currently enabled in the base route.</p>

<pre><code>Route::get('/', function () {
   if (Auth::check()) {
      UserService::verifyAccount();
   }
   return redirect('/home');
});
</code></pre>

<p>My problem is currently this only works for the home/base route. I was hoping there would be an easier way to implement for ALL routes without having to manually copy and paste to each route. </p>

<p>I would love to use the route group feature <code>['middleware' =&gt; 'auth']</code> to my routes. but i cant because the website allows for both guest and authenticated users. </p>

<p>any help would be appreciated. </p>