Setting the Authentication User Provider

Problem

You want to use a different user provider for authentication.

Solution

Use the Auth::setProvider() method.

Auth::setProvider($user_provider);

The provider must implement Illuminate\Auth\UserProviderInterface.

Discussion

This is an advanced topic.

Generally, the authentication driver you use will automatically set up the correct user provider.

But this method is available for customization. Make sure you call this method before the authentication routines are accessed. Either a service provider or in app/start/global.php is a good location.

comments powered by Disqus