Add actions

This commit is contained in:
2023-12-08 09:19:43 +05:00
parent 87ea9afe63
commit 374dfe8da1
7 changed files with 38 additions and 11 deletions

View File

@@ -13,6 +13,10 @@ class LoanOrderPolicy
*/
public function viewAny(User $user): bool
{
if ($user->isOperator() && $user->cannot('viewLoanOrders')) {
return false;
}
return true;
}
@@ -25,7 +29,7 @@ class LoanOrderPolicy
return true;
}
if ($user->isOperator()) {
if ($user->isOperator() && $user->can('viewLoanOrders')) {
return $user->branches()->where('branches.id', $loanOrder->branch_id)->exists();
}
@@ -41,6 +45,10 @@ class LoanOrderPolicy
*/
public function create(User $user): bool
{
if ($user->isOperator() && $user->cannot('viewLoanOrders')) {
return false;
}
return true;
}
@@ -53,7 +61,7 @@ class LoanOrderPolicy
return true;
}
if ($user->isOperator()) {
if ($user->isOperator() && $user->can('viewLoanOrders')) {
return $user->branches()->where('branches.id', $loanOrder->branch_id)->exists();
}
@@ -75,7 +83,7 @@ class LoanOrderPolicy
return true;
}
if ($user->isOperator()) {
if ($user->isOperator() && $user->can('viewLoanOrders')) {
return $user->branches()->where('branches.id', $loanOrder->branch_id)->exists();
}