feat: pindah route ke /dashboard, tambah seeders, business rules via observers, action verifikasi & approval
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use App\Models\MemberStatusLog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UserObserver
|
||||
{
|
||||
public function updated(User $user): void
|
||||
{
|
||||
// Log perubahan status anggota
|
||||
if ($user->wasChanged('status')) {
|
||||
MemberStatusLog::create([
|
||||
'member_id' => $user->id,
|
||||
'changed_by' => Auth::id() ?? $user->id,
|
||||
'old_status' => $user->getOriginal('status'),
|
||||
'new_status' => $user->status,
|
||||
'reason' => $user->inactive_reason,
|
||||
]);
|
||||
|
||||
ActivityLog::create([
|
||||
'user_id' => Auth::id(),
|
||||
'action' => 'status_changed',
|
||||
'model_type' => User::class,
|
||||
'model_id' => $user->id,
|
||||
'description' => "Status anggota {$user->name} diubah dari {$user->getOriginal('status')} menjadi {$user->status}",
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function created(User $user): void
|
||||
{
|
||||
ActivityLog::create([
|
||||
'user_id' => Auth::id(),
|
||||
'action' => 'created',
|
||||
'model_type' => User::class,
|
||||
'model_id' => $user->id,
|
||||
'description' => "Anggota baru {$user->name} ditambahkan",
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user