パッケージのインストール
composer require yadahan/laravel-authentication-log
設定ファイルの自動作成
php artisan vendor:publish --provider="Yadahan\AuthenticationLog\AuthenticationLogServiceProvider"
DBテーブル「authentication_log」の自動作成
php artisan migrate
次のトレイトを追加します
use Notifiable; // 通知
use \Yadahan\AuthenticationLog\AuthenticationLogable; // ログ
これでokです。
ログイン後にDBを確認すると、テーブル「authentication_log」へログイン ID とユーザーエージェントが記録されているのが確認できると思います。
resources/views/home.blade.php
最終ログイン
{{ @Auth::user()->lastLoginAt() }}
最終ログインIP
{{ @Auth::user()->lastLoginIp() }}