Getting the Authentication User Provider

Problem

You want to access the user provider the authentication uses.

Solution

Use the Auth::getProvider() method.

$provider = Auth::getProvider();

Discussion

The provider will be based on how your authentication is configured.

It'll be the provider for the driver you set up in the your app/config/auth.php. See Changing Your Authentication Driver.

If you're using the database configuration driver, the provider will be Illuminate\Auth\DatabaseUserProvider. If you're using the eloquent configuration driver the provider will be Illuminate\Auth\EloquentUserProvider.

If you set up a custom authentication driver, the user provider will be whatever you set up.

comments powered by Disqus