loan order permissions

This commit is contained in:
nurmuhammet committed 2023-11-30 17:09:02 +05:00
1 parent 3818b5fb63
commit b07b919f18
7 files changed
+149 -46

No files matched your search

+26 -10
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 @@ public function view(User $user, LoanOrder $loanOrder): bool
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 @@ public function view(User $user, LoanOrder $loanOrder): bool
*/
public function create(User $user): bool
{
if ($user->isAdmin()) {
return true;
}
return false;
return true;
}
/**
@@ -52,6 +52,14 @@ public function update(User $user, LoanOrder $loanOrder): bool
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 @@ public function delete(User $user, LoanOrder $loanOrder): bool
return true;
}
if ($user->isOperator()) {
return $user->branches()->where('id', $loanOrder->branch_id)->exists();
}
if ($user->ownsLoanOrder($loanOrder)) {
return true;
}
return false;
}