From 704e4c63dcf449641c5b98dc5433958554b96a91 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Thu, 10 Apr 2025 00:39:38 +0100 Subject: Updated auth_log_table seeder --- database/migrations/0000_00_00_000000_create_auth_log_table.php | 4 +++- src/AuthLogServiceProvider.php | 3 +++ src/Models/AuthLog.php | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/database/migrations/0000_00_00_000000_create_auth_log_table.php b/database/migrations/0000_00_00_000000_create_auth_log_table.php index 64f905b..36d7e97 100644 --- a/database/migrations/0000_00_00_000000_create_auth_log_table.php +++ b/database/migrations/0000_00_00_000000_create_auth_log_table.php @@ -1,5 +1,7 @@ id(); $table->foreignId('user_id')->nullable(); - $table->enum('status', ['login_success', 'login_failure', 'logout']); + $table->enum('status', Status::values()); $table->jsonb('properties')->nullable(); $table->timestamp('created_at'); }); diff --git a/src/AuthLogServiceProvider.php b/src/AuthLogServiceProvider.php index 55cc2c2..f104997 100644 --- a/src/AuthLogServiceProvider.php +++ b/src/AuthLogServiceProvider.php @@ -3,6 +3,7 @@ namespace Lightscale\LaralightAuthLog; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Facades\Event; class AuthLogServiceProvider extends ServiceProvider { @@ -20,5 +21,7 @@ class AuthLogServiceProvider extends ServiceProvider $this->publishes([ "{$root}/config/access_log.php" => config_path('auth_log.php'), ], "{$ns}:config"); + + Event::subscribe(AuthSubscriber::class); } } diff --git a/src/Models/AuthLog.php b/src/Models/AuthLog.php index a5b1280..597888a 100644 --- a/src/Models/AuthLog.php +++ b/src/Models/AuthLog.php @@ -2,6 +2,8 @@ namespace Lightscale\LaralightAuthLog\Models; +use Lightscale\LaralightAuthLog\Enums\Status; + use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Prunable; @@ -27,6 +29,7 @@ class AuthLog extends Model protected function casts(): array { return [ + 'status' => Status::class, 'properties' => 'collection', ]; } -- cgit v1.2.3