I have a pretty straight forward middleware:
protected $auth;
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
//dd($this->auth->user());
if($this->auth->user()->id && $this->auth->user()->pastDueFees()){
\Session::flash('message','You must pay past due deal fees before using the rest of the website');
return redirect()->route('profile.investment-fees');
}
return $next($request);
}
This causes the redirect loop. I am only calling the middleware via Kernel.php.
My Kernal.php:
<?php namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel {
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
'App\Http\Middleware\VerifyCsrfToken',
'App\Http\Middleware\FeesOwed'
];
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.signed' => 'App\Http\Middleware\AuthenticateSigned',
'fees' => 'App\Http\Middleware\FeesOwed',
'auth.subscribed' => 'App\Http\Middleware\AuthenticateSubscribed',
'admin' => 'App\Http\Middleware\AuthenticateAdmin',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
];
}
thanks in advance.
profile.investment-fees
route right? - jfadichprofile.investment-fees
as well. When you try to redirect to that route it tries to redirect again becausepastDueFees()
hasn't changed - jfadich$routeMiddleware
and not$middlewareGroups
or$middleware
- Carlos