I would create my own UserProvider service that contains the methods I want, and then extend Auth.
I recommend creating your own service provider or directly extending the Auth class in one of the startup files (for example, start/global.php ).
Auth::extend('nonDescriptAuth', function() { return new Guard( new NonDescriptUserProvider(), App::make('session.store') ); });
This is a good tutorial that you can use for a better understanding.
There is another method that you could use. This will be due to the distribution of one of the current suppliers, such as Eloquent.
class MyProvider extends Illuminate\Auth\EloquentUserProvider { public function myCustomMethod() {
Then you can simply extend auth as described above, but with your custom provider.
\Auth::extend('nonDescriptAuth', function() { return new \Illuminate\Auth\Guard( new MyProvider( new \Illuminate\Hashing\BcryptHasher, \Config::get('auth.model') ), \App::make('session.store') ); });
After you injected the code, you would modify the driver in the auth.php configuration file to use 'nonDescriptAuth`.
source share