- 1. 概要
- 2. 対応
1. 概要
お次は。
Trait "Laravel\Sanctum\HasApiTokens" not found
2. 対応
これは、単純にインストールするモジュールが足りていない。
「api」というモジュールをインストールします。
所有権の設定を変更して。
プロジェクトのディレクトリで。
php artisan install:api
下記のようなメッセージが表示されます。
./composer.json has been updated
Running composer update laravel/sanctum
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking laravel/sanctum (v4.0.8)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Downloading laravel/sanctum (v4.0.8)
- Installing laravel/sanctum (v4.0.8): Extracting archive
Generating optimized autoload files
Class App\Http\Controllers\Api\ParallelApi located in ./app/Http/Controllers/Api/StrengthController.php does not comply with psr-4 autoloading standard (rule: App\ => ./app). Skipping.
Class App\Http\Controllers\Functions\EffectiveStrength located in ./app/Http/Controllers/Functions/CalcGraphController.php does not comply with psr-4 autoloading standard (rule: App\ => ./app). Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
INFO Discovering packages.
laravel/pail .......................................................... DONE
laravel/sail .......................................................... DONE
laravel/sanctum ....................................................... DONE
laravel/tinker ........................................................ DONE
laravel/ui ............................................................ DONE
nesbot/carbon ......................................................... DONE
nunomaduro/collision .................................................. DONE
nunomaduro/termwind ................................................... DONE
80 packages you are using are looking for funding.
Use the 'composer fund' command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
INFO No publishable resources for tag [laravel-assets].
No security vulnerability advisories found.
INFO Published API routes file.
One new database migration has been published. Would you like to run all pending database migrations? (yes/no) [yes]:
INFO API scaffolding installed. Please add the [Laravel\Sanctum\HasApiTokens] trait to your User model.
データベースを作成するかという「(yes/no) [yes]:」には、既存のデータベースがあるのであれば、「no」で答えます。
インストールが終わったら、所有権をもとに戻します。
キャッシュ等をクリアして、ウェブサーバを再起動します。
|
|