54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Auth\Events\Registered;
|
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Auth\Events\Login;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class EventServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The event to listener mappings for the application.
|
|
*
|
|
* @var array<class-string, array<int, class-string>>
|
|
*/
|
|
protected $listen = [
|
|
Registered::class => [
|
|
SendEmailVerificationNotification::class,
|
|
],
|
|
];
|
|
|
|
/**
|
|
* Register any events for your application.
|
|
*/
|
|
public function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
// Mendaftarkan listener untuk event login
|
|
// Event::listen(Login::class, function ($event) {
|
|
// // Mencatat log informasi login
|
|
// Log::info('User Login', [
|
|
// 'user_id' => $event->user->id,
|
|
// 'fullname' => $event->user->fullname, // Menggunakan fullname dari model User
|
|
// 'username' => $event->user->username, // Juga mencatat username
|
|
// 'role' => $event->user->role, // Mencatat role pengguna jika diperlukan
|
|
// 'os' => request()->header('User-Agent'), // Mendapatkan OS dari User-Agent
|
|
// 'login_time' => now()->toDateTimeString(), // Waktu login
|
|
// ]);
|
|
// });
|
|
}
|
|
|
|
/**
|
|
* Determine if events and listeners should be automatically discovered.
|
|
*/
|
|
public function shouldDiscoverEvents(): bool
|
|
{
|
|
return false;
|
|
}
|
|
}
|