custom-guard
Custom guard
Starting with Voyager 1.2 you can define a (custom) guard which is used throughout Voyager.
To do so, just bind the name of your auth-guard to VoyagerGuard
.
First, make sure you have defined a guard as per the Laravel documentation.
After that open your AuthServiceProvider
and add the following to the register method:
Now this guard is used instead of the default guard.
Example - using a different model and table for Admins
First you have to create a new table. Let's call it admins
:
and a model which extends Voyagers user-model:
Next, create a guard named admin
in your config/auth.php
:
And a user provider called admins
:
Next you have to tell Voyager to use your new guard.
Open you AppServiceProvider.php
and add the following to the register
method:
Please note that the user-bread is still responsible to edit users - not admins.
Create a BREAD for the admins
table if you want to change Admins.
Last updated