diff options
-rw-r--r-- | database/migrations/0000_00_00_000000_create_auth_log_table.php | 4 | ||||
-rw-r--r-- | src/AuthLogServiceProvider.php | 3 | ||||
-rw-r--r-- | src/Models/AuthLog.php | 3 |
3 files changed, 9 insertions, 1 deletions
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 @@ <?php +use Lightscale\LaralightAuthLog\Enums\Status; + use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,7 +16,7 @@ return new class extends Migration Schema::create(config('auth_log.table_name'), function (Blueprint $table) { $table->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', ]; } |