loan order permissions

This commit is contained in:
2023-11-30 17:09:02 +05:00
parent 3818b5fb63
commit b07b919f18
7 changed files with 149 additions and 46 deletions

View File

@@ -12,11 +12,7 @@ class LoanOrderPolicy
*/
public function viewAny(User $user): bool
{
if ($user->isAdmin()) {
return true;
}
return false;
return true;
}
/**
@@ -28,6 +24,14 @@ class LoanOrderPolicy
return true;
}
if ($user->isOperator()) {
return $user->branches()->where('id', $loanOrder->branch_id)->exists();
}
if ($user->ownsLoanOrder($loanOrder)) {
return true;
}
return false;
}
@@ -36,11 +40,7 @@ class LoanOrderPolicy
*/
public function create(User $user): bool
{
if ($user->isAdmin()) {
return true;
}
return false;
return true;
}
/**
@@ -52,6 +52,14 @@ class LoanOrderPolicy
return true;
}
if ($user->isOperator()) {
return $user->branches()->where('id', $loanOrder->branch_id)->exists();
}
if ($user->ownsLoanOrder($loanOrder)) {
return true;
}
return false;
}
@@ -64,6 +72,14 @@ class LoanOrderPolicy
return true;
}
if ($user->isOperator()) {
return $user->branches()->where('id', $loanOrder->branch_id)->exists();
}
if ($user->ownsLoanOrder($loanOrder)) {
return true;
}
return false;
}