How i can change dynamicaly my auth guard ?
For example if route prefix is /admin i need use admin auth guard
and if route prefix is /customer i need use customer auth guard?
Now i need write some like this
Auth::guard('admin')->user()
Create middleware to make this happen, you can change default guard on the fly $this->app['auth']->setDefaultDriver('admin');.
Solution ready to cmd+c && cmd+v: http://mattallan.org/2016/setting-the-guard-per-route-in-laravel/
Next time search.
@Kyslik Very useful snippet! Thank you.
You can also use the shouldUse() method on the AuthManager class. Then, in your controller, call Auth::shouldUse('guardName'); Then, all future calls to auth() will use that guard.
@gopal-g I just got the notification from GitHub about this now 馃ぃ .
Most helpful comment
Create middleware to make this happen, you can change default guard on the fly
$this->app['auth']->setDefaultDriver('admin');.Solution ready to
cmd+c&&cmd+v: http://mattallan.org/2016/setting-the-guard-per-route-in-laravel/Next time search.