i have installed laravel sanctum package for authorization system. everything works fine. i can make api call and other things properly. but when i tried to make a policy for restricting a user to access some data by using command php artisan make:policy QuestionPolicy, it throwed following error.(pa is alias for php artisan i have defined.)
what is causing issue and how can i solve it?
rex@primus:~/rajesh/code/erworks/codalaya/codalaya-laravel-v8$ pa make:policy CategoryPolicy
LogicException
The [sanctum] guard is not defined in your "auth" configuration file.
at vendor/laravel/framework/src/Illuminate/Foundation/Console/PolicyMakeCommand.php:85
81▕
82▕ $guard = $this->option('guard') ?: $config->get('auth.defaults.guard');
83▕
84▕ if (is_null($guardProvider = $config->get('auth.guards.'.$guard.'.provider'))) {
➜ 85▕ throw new LogicException('The ['.$guard.'] guard is not defined in your "auth" configuration file.');
86▕ }
87▕
88▕ return $config->get(
89▕ 'auth.providers.'.$guardProvider.'.model'
+17 vendor frames
18 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
rex@primus:~/rajesh/code/erworks/codalaya/codalaya-laravel-v8$
as i understand i can use sanctum guard without mentioning it in auth.php config file.
here is my auth.php file.
<?php
return [
'defaults' => [
'guard' => 'sanctum',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
'password_timeout' => 10800,
];