check permission before showing notifications

This commit is contained in:
Denis Duliçi
2021-02-24 19:14:18 +03:00
parent 1677a930ac
commit 0d3f34ae8f
2 changed files with 70 additions and 62 deletions

View File

@ -35,20 +35,22 @@ class Header
];
}
$unreads = $user->unreadNotifications;
if ($user->can('read-common-notifications')) {
$unreads = $user->unreadNotifications;
foreach ($unreads as $unread) {
$data = $unread->getAttribute('data');
foreach ($unreads as $unread) {
$data = $unread->getAttribute('data');
switch ($unread->getAttribute('type')) {
case 'App\Notifications\Purchase\Bill':
$bills[$data['bill_id']] = $data['amount'];
$notifications++;
break;
case 'App\Notifications\Sale\Invoice':
$invoices[$data['invoice_id']] = $data['amount'];
$notifications++;
break;
switch ($unread->getAttribute('type')) {
case 'App\Notifications\Purchase\Bill':
$bills[$data['bill_id']] = $data['amount'];
$notifications++;
break;
case 'App\Notifications\Sale\Invoice':
$invoices[$data['invoice_id']] = $data['amount'];
$notifications++;
break;
}
}
}