fix some revisi

This commit is contained in:
Jagad R R
2025-01-19 14:57:01 +07:00
parent 430700bc59
commit 1610d83bc6
17 changed files with 562 additions and 477 deletions
@@ -104,27 +104,12 @@ class DashboardController extends Controller
public function notifications()
{
$this->checkAuthorization(auth()->user(), ['notification.view']);
$role = auth()->user()->getRoleNames()[0];
// Mulai dengan query dasar
$notifications = Notifications::orderBy('created_at', 'desc')
->where('receiver_id', auth()->user()->id)
->where('is_read', 0);
// Tambahkan filter berdasarkan role
if ($role == 'Admin Region') {
$notifications->where('type', 'new_expense');
} elseif ($role == 'Marketing Operational Manager Region') {
$notifications->where('type', 'approve2_expense');
} elseif ($role == 'Area Manager Cabang' || $role == 'Marketing Information System') {
$notifications->where('type', 'approve_expense');
} elseif ($role == 'Head of Sales Marketing') {
$notifications->where('type', 'approve2_expense');
} else {
// Jika tidak ada role yang sesuai, kembalikan koleksi kosong
return response()->json([]);
}
// Ambil data dan kembalikan sebagai JSON
return response()->json($notifications->limit(6)->get());
}