Creating an Instance of the Auth Database Driver

Problem

You want to create an instance of the database driver.

Solution

Use the Auth::createDatabaseDriver() method.

$driver = Auth::createDatabaseDriver();

Once you have the $driver above you can call the standard check(), guest(), user(), etc. methods directly on the driver.

Discussion

Generally, it's better to use the Auth facade.

This sets up the appropriate driver based on your configuration driver. But if your application is complex, you can instantiate the driver separately to have multiple authentication drivers active at one time.

comments powered by Disqus