check permission before showing notifications
This commit is contained in:
parent
1677a930ac
commit
0d3f34ae8f
@ -35,20 +35,22 @@ class Header
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$unreads = $user->unreadNotifications;
|
if ($user->can('read-common-notifications')) {
|
||||||
|
$unreads = $user->unreadNotifications;
|
||||||
|
|
||||||
foreach ($unreads as $unread) {
|
foreach ($unreads as $unread) {
|
||||||
$data = $unread->getAttribute('data');
|
$data = $unread->getAttribute('data');
|
||||||
|
|
||||||
switch ($unread->getAttribute('type')) {
|
switch ($unread->getAttribute('type')) {
|
||||||
case 'App\Notifications\Purchase\Bill':
|
case 'App\Notifications\Purchase\Bill':
|
||||||
$bills[$data['bill_id']] = $data['amount'];
|
$bills[$data['bill_id']] = $data['amount'];
|
||||||
$notifications++;
|
$notifications++;
|
||||||
break;
|
break;
|
||||||
case 'App\Notifications\Sale\Invoice':
|
case 'App\Notifications\Sale\Invoice':
|
||||||
$invoices[$data['invoice_id']] = $data['amount'];
|
$invoices[$data['invoice_id']] = $data['amount'];
|
||||||
$notifications++;
|
$notifications++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,62 +141,68 @@
|
|||||||
|
|
||||||
@stack('navbar_notifications')
|
@stack('navbar_notifications')
|
||||||
|
|
||||||
<li class="nav-item dropdown">
|
@can('read-common-notifications')
|
||||||
<a class="nav-link" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<li class="nav-item dropdown">
|
||||||
<span>
|
<a class="nav-link" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i class="far fa-bell"></i>
|
<span>
|
||||||
</span>
|
<i class="far fa-bell"></i>
|
||||||
@if ($notifications)
|
</span>
|
||||||
<span class="badge badge-md badge-circle badge-reminder badge-warning">{{ $notifications }}</span>
|
@if ($notifications)
|
||||||
@endif
|
<span class="badge badge-md badge-circle badge-reminder badge-warning">{{ $notifications }}</span>
|
||||||
</a>
|
@endif
|
||||||
|
</a>
|
||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right py-0 overflow-hidden">
|
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right py-0 overflow-hidden">
|
||||||
@if ($notifications)
|
@if ($notifications)
|
||||||
<div class="p-3">
|
<div class="p-3">
|
||||||
<a class="text-sm text-muted">{{ trans_choice('header.notifications.counter', $notifications, ['count' => $notifications]) }}</a>
|
<a class="text-sm text-muted">{{ trans_choice('header.notifications.counter', $notifications, ['count' => $notifications]) }}</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
|
|
||||||
<div class="list-group list-group-flush">
|
|
||||||
@if (count($bills))
|
|
||||||
<a href="{{ route('users.read.bills', $user->id) }}" class="list-group-item list-group-item-action">
|
|
||||||
<div class="row align-items-center">
|
|
||||||
<div class="col-auto">
|
|
||||||
<i class="fa fa-shopping-cart"></i>
|
|
||||||
</div>
|
|
||||||
<div class="col ml--2">
|
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
|
||||||
<h4 class="mb-0 text-sm">{{ trans_choice('header.notifications.upcoming_bills', count($bills), ['count' => count($bills)]) }}</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (count($invoices))
|
<div class="list-group list-group-flush">
|
||||||
<a href="{{ route('users.read.invoices', $user->id) }}" class="list-group-item list-group-item-action">
|
@can('read-purchases-bills')
|
||||||
<div class="row align-items-center">
|
@if (count($bills))
|
||||||
<div class="col-auto">
|
<a href="{{ route('users.read.bills', $user->id) }}" class="list-group-item list-group-item-action">
|
||||||
<i class="fa fa-money-bill"></i>
|
<div class="row align-items-center">
|
||||||
</div>
|
<div class="col-auto">
|
||||||
<div class="col ml--2">
|
<i class="fa fa-shopping-cart"></i>
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
</div>
|
||||||
<h4 class="mb-0 text-sm">{{ trans_choice('header.notifications.overdue_invoices', count($invoices), ['count' => count($invoices)]) }}</h4>
|
<div class="col ml--2">
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<h4 class="mb-0 text-sm">{{ trans_choice('header.notifications.upcoming_bills', count($bills), ['count' => count($bills)]) }}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
@endif
|
||||||
</a>
|
@endcan
|
||||||
|
|
||||||
|
@can('read-sales-invoices')
|
||||||
|
@if (count($invoices))
|
||||||
|
<a href="{{ route('users.read.invoices', $user->id) }}" class="list-group-item list-group-item-action">
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col-auto">
|
||||||
|
<i class="fa fa-money-bill"></i>
|
||||||
|
</div>
|
||||||
|
<div class="col ml--2">
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<h4 class="mb-0 text-sm">{{ trans_choice('header.notifications.overdue_invoices', count($invoices), ['count' => count($invoices)]) }}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
@endcan
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if ($notifications)
|
||||||
|
<a href="#" class="dropdown-item text-center text-primary font-weight-bold py-3">{{ trans('header.notifications.view_all') }}</a>
|
||||||
|
@else
|
||||||
|
<a class="dropdown-item text-center text-primary font-weight-bold py-3">{{ trans_choice('header.notifications.counter', $notifications, ['count' => $notifications]) }}</a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
@if ($notifications)
|
@endcan
|
||||||
<a href="#" class="dropdown-item text-center text-primary font-weight-bold py-3">{{ trans('header.notifications.view_all') }}</a>
|
|
||||||
@else
|
|
||||||
<a class="dropdown-item text-center text-primary font-weight-bold py-3">{{ trans_choice('header.notifications.counter', $notifications, ['count' => $notifications]) }}</a>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
@stack('navbar_updates')
|
@stack('navbar_updates')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user