fix some revisi
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ class ReportController extends Controller
|
||||
} else {
|
||||
$cabangs = Cabang::all();
|
||||
$regions = Region::all();
|
||||
$forms = FormHelper::getAllForms($month, $year)->sortByDesc('created_at');
|
||||
$forms = FormHelper::getAllForms2()->sortByDesc('created_at');
|
||||
}
|
||||
|
||||
// get all params in url
|
||||
@@ -565,7 +565,7 @@ class ReportController extends Controller
|
||||
} else {
|
||||
$cabangs = Cabang::all();
|
||||
$regions = Region::all();
|
||||
$forms = FormHelper::getAllForms($month, $year)->sortByDesc('tanggal')->sortByDesc('created_at');
|
||||
$forms = FormHelper::getAllForms($month, $year)->sortByDesc('tanggal')->sortByDesc('created_at');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user