From 711b5373da7f76fea2d7f7aeb1e6467fcfddb6d0 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Mon, 3 Nov 2025 09:15:36 +0500 Subject: [PATCH] add policies --- app/Modules/Branch/Policies/BranchPolicy.php | 70 +++++++++++++++++++ app/Modules/Card/Policies/CardPolicy.php | 70 +++++++++++++++++++ .../CardOrder/Policies/CardOrderPolicy.php | 70 +++++++++++++++++++ .../CardOrder/Policies/CardStatePolicy.php | 70 +++++++++++++++++++ .../CardOrder/Policies/CardTypePolicy.php | 70 +++++++++++++++++++ .../Policies/CardPinOrderPolicy.php | 70 +++++++++++++++++++ app/Modules/Loan/Policies/LoanPolicy.php | 70 +++++++++++++++++++ .../LoanOrder/Policies/LoanOrderPolicy.php | 70 +++++++++++++++++++ .../Policies/LoanOrderRequiredDocsPolicy.php | 70 +++++++++++++++++++ .../LoanOrder/Policies/LoanTypePolicy.php | 70 +++++++++++++++++++ .../Policies/LoanPaidOffLetterPolicy.php | 70 +++++++++++++++++++ .../Province/Policies/ProvincePolicy.php | 70 +++++++++++++++++++ app/Policies/RolePolicy.php | 7 +- app/Policies/UserPolicy.php | 67 ++++++++++++++++++ 14 files changed, 911 insertions(+), 3 deletions(-) create mode 100644 app/Modules/Branch/Policies/BranchPolicy.php create mode 100644 app/Modules/Card/Policies/CardPolicy.php create mode 100644 app/Modules/CardOrder/Policies/CardOrderPolicy.php create mode 100644 app/Modules/CardOrder/Policies/CardStatePolicy.php create mode 100644 app/Modules/CardOrder/Policies/CardTypePolicy.php create mode 100644 app/Modules/CardPinOrder/Policies/CardPinOrderPolicy.php create mode 100644 app/Modules/Loan/Policies/LoanPolicy.php create mode 100644 app/Modules/LoanOrder/Policies/LoanOrderPolicy.php create mode 100644 app/Modules/LoanOrder/Policies/LoanOrderRequiredDocsPolicy.php create mode 100644 app/Modules/LoanOrder/Policies/LoanTypePolicy.php create mode 100644 app/Modules/LoanPaidOffLetter/Policies/LoanPaidOffLetterPolicy.php create mode 100644 app/Modules/Province/Policies/ProvincePolicy.php create mode 100644 app/Policies/UserPolicy.php diff --git a/app/Modules/Branch/Policies/BranchPolicy.php b/app/Modules/Branch/Policies/BranchPolicy.php new file mode 100644 index 0000000..79e46aa --- /dev/null +++ b/app/Modules/Branch/Policies/BranchPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:Branch'); + } + + public function view(AuthUser $authUser, Branch $branch): bool + { + return $authUser->can('View:Branch'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:Branch'); + } + + public function update(AuthUser $authUser, Branch $branch): bool + { + return $authUser->can('Update:Branch'); + } + + public function delete(AuthUser $authUser, Branch $branch): bool + { + return $authUser->can('Delete:Branch'); + } + + public function restore(AuthUser $authUser, Branch $branch): bool + { + return $authUser->can('Restore:Branch'); + } + + public function forceDelete(AuthUser $authUser, Branch $branch): bool + { + return $authUser->can('ForceDelete:Branch'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:Branch'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:Branch'); + } + + public function replicate(AuthUser $authUser, Branch $branch): bool + { + return $authUser->can('Replicate:Branch'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:Branch'); + } + +} \ No newline at end of file diff --git a/app/Modules/Card/Policies/CardPolicy.php b/app/Modules/Card/Policies/CardPolicy.php new file mode 100644 index 0000000..67ba4e0 --- /dev/null +++ b/app/Modules/Card/Policies/CardPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:Card'); + } + + public function view(AuthUser $authUser, Card $card): bool + { + return $authUser->can('View:Card'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:Card'); + } + + public function update(AuthUser $authUser, Card $card): bool + { + return $authUser->can('Update:Card'); + } + + public function delete(AuthUser $authUser, Card $card): bool + { + return $authUser->can('Delete:Card'); + } + + public function restore(AuthUser $authUser, Card $card): bool + { + return $authUser->can('Restore:Card'); + } + + public function forceDelete(AuthUser $authUser, Card $card): bool + { + return $authUser->can('ForceDelete:Card'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:Card'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:Card'); + } + + public function replicate(AuthUser $authUser, Card $card): bool + { + return $authUser->can('Replicate:Card'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:Card'); + } + +} \ No newline at end of file diff --git a/app/Modules/CardOrder/Policies/CardOrderPolicy.php b/app/Modules/CardOrder/Policies/CardOrderPolicy.php new file mode 100644 index 0000000..280ea6d --- /dev/null +++ b/app/Modules/CardOrder/Policies/CardOrderPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:CardOrder'); + } + + public function view(AuthUser $authUser, CardOrder $cardOrder): bool + { + return $authUser->can('View:CardOrder'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:CardOrder'); + } + + public function update(AuthUser $authUser, CardOrder $cardOrder): bool + { + return $authUser->can('Update:CardOrder'); + } + + public function delete(AuthUser $authUser, CardOrder $cardOrder): bool + { + return $authUser->can('Delete:CardOrder'); + } + + public function restore(AuthUser $authUser, CardOrder $cardOrder): bool + { + return $authUser->can('Restore:CardOrder'); + } + + public function forceDelete(AuthUser $authUser, CardOrder $cardOrder): bool + { + return $authUser->can('ForceDelete:CardOrder'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:CardOrder'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:CardOrder'); + } + + public function replicate(AuthUser $authUser, CardOrder $cardOrder): bool + { + return $authUser->can('Replicate:CardOrder'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:CardOrder'); + } + +} \ No newline at end of file diff --git a/app/Modules/CardOrder/Policies/CardStatePolicy.php b/app/Modules/CardOrder/Policies/CardStatePolicy.php new file mode 100644 index 0000000..dd4d3ad --- /dev/null +++ b/app/Modules/CardOrder/Policies/CardStatePolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:CardState'); + } + + public function view(AuthUser $authUser, CardState $cardState): bool + { + return $authUser->can('View:CardState'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:CardState'); + } + + public function update(AuthUser $authUser, CardState $cardState): bool + { + return $authUser->can('Update:CardState'); + } + + public function delete(AuthUser $authUser, CardState $cardState): bool + { + return $authUser->can('Delete:CardState'); + } + + public function restore(AuthUser $authUser, CardState $cardState): bool + { + return $authUser->can('Restore:CardState'); + } + + public function forceDelete(AuthUser $authUser, CardState $cardState): bool + { + return $authUser->can('ForceDelete:CardState'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:CardState'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:CardState'); + } + + public function replicate(AuthUser $authUser, CardState $cardState): bool + { + return $authUser->can('Replicate:CardState'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:CardState'); + } + +} \ No newline at end of file diff --git a/app/Modules/CardOrder/Policies/CardTypePolicy.php b/app/Modules/CardOrder/Policies/CardTypePolicy.php new file mode 100644 index 0000000..b58550f --- /dev/null +++ b/app/Modules/CardOrder/Policies/CardTypePolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:CardType'); + } + + public function view(AuthUser $authUser, CardType $cardType): bool + { + return $authUser->can('View:CardType'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:CardType'); + } + + public function update(AuthUser $authUser, CardType $cardType): bool + { + return $authUser->can('Update:CardType'); + } + + public function delete(AuthUser $authUser, CardType $cardType): bool + { + return $authUser->can('Delete:CardType'); + } + + public function restore(AuthUser $authUser, CardType $cardType): bool + { + return $authUser->can('Restore:CardType'); + } + + public function forceDelete(AuthUser $authUser, CardType $cardType): bool + { + return $authUser->can('ForceDelete:CardType'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:CardType'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:CardType'); + } + + public function replicate(AuthUser $authUser, CardType $cardType): bool + { + return $authUser->can('Replicate:CardType'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:CardType'); + } + +} \ No newline at end of file diff --git a/app/Modules/CardPinOrder/Policies/CardPinOrderPolicy.php b/app/Modules/CardPinOrder/Policies/CardPinOrderPolicy.php new file mode 100644 index 0000000..bafdd3c --- /dev/null +++ b/app/Modules/CardPinOrder/Policies/CardPinOrderPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:CardPinOrder'); + } + + public function view(AuthUser $authUser, CardPinOrder $cardPinOrder): bool + { + return $authUser->can('View:CardPinOrder'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:CardPinOrder'); + } + + public function update(AuthUser $authUser, CardPinOrder $cardPinOrder): bool + { + return $authUser->can('Update:CardPinOrder'); + } + + public function delete(AuthUser $authUser, CardPinOrder $cardPinOrder): bool + { + return $authUser->can('Delete:CardPinOrder'); + } + + public function restore(AuthUser $authUser, CardPinOrder $cardPinOrder): bool + { + return $authUser->can('Restore:CardPinOrder'); + } + + public function forceDelete(AuthUser $authUser, CardPinOrder $cardPinOrder): bool + { + return $authUser->can('ForceDelete:CardPinOrder'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:CardPinOrder'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:CardPinOrder'); + } + + public function replicate(AuthUser $authUser, CardPinOrder $cardPinOrder): bool + { + return $authUser->can('Replicate:CardPinOrder'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:CardPinOrder'); + } + +} \ No newline at end of file diff --git a/app/Modules/Loan/Policies/LoanPolicy.php b/app/Modules/Loan/Policies/LoanPolicy.php new file mode 100644 index 0000000..950f18a --- /dev/null +++ b/app/Modules/Loan/Policies/LoanPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:Loan'); + } + + public function view(AuthUser $authUser, Loan $loan): bool + { + return $authUser->can('View:Loan'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:Loan'); + } + + public function update(AuthUser $authUser, Loan $loan): bool + { + return $authUser->can('Update:Loan'); + } + + public function delete(AuthUser $authUser, Loan $loan): bool + { + return $authUser->can('Delete:Loan'); + } + + public function restore(AuthUser $authUser, Loan $loan): bool + { + return $authUser->can('Restore:Loan'); + } + + public function forceDelete(AuthUser $authUser, Loan $loan): bool + { + return $authUser->can('ForceDelete:Loan'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:Loan'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:Loan'); + } + + public function replicate(AuthUser $authUser, Loan $loan): bool + { + return $authUser->can('Replicate:Loan'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:Loan'); + } + +} \ No newline at end of file diff --git a/app/Modules/LoanOrder/Policies/LoanOrderPolicy.php b/app/Modules/LoanOrder/Policies/LoanOrderPolicy.php new file mode 100644 index 0000000..63121d6 --- /dev/null +++ b/app/Modules/LoanOrder/Policies/LoanOrderPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:LoanOrder'); + } + + public function view(AuthUser $authUser, LoanOrder $loanOrder): bool + { + return $authUser->can('View:LoanOrder'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:LoanOrder'); + } + + public function update(AuthUser $authUser, LoanOrder $loanOrder): bool + { + return $authUser->can('Update:LoanOrder'); + } + + public function delete(AuthUser $authUser, LoanOrder $loanOrder): bool + { + return $authUser->can('Delete:LoanOrder'); + } + + public function restore(AuthUser $authUser, LoanOrder $loanOrder): bool + { + return $authUser->can('Restore:LoanOrder'); + } + + public function forceDelete(AuthUser $authUser, LoanOrder $loanOrder): bool + { + return $authUser->can('ForceDelete:LoanOrder'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:LoanOrder'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:LoanOrder'); + } + + public function replicate(AuthUser $authUser, LoanOrder $loanOrder): bool + { + return $authUser->can('Replicate:LoanOrder'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:LoanOrder'); + } + +} \ No newline at end of file diff --git a/app/Modules/LoanOrder/Policies/LoanOrderRequiredDocsPolicy.php b/app/Modules/LoanOrder/Policies/LoanOrderRequiredDocsPolicy.php new file mode 100644 index 0000000..3fa0e8e --- /dev/null +++ b/app/Modules/LoanOrder/Policies/LoanOrderRequiredDocsPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:LoanOrderRequiredDocs'); + } + + public function view(AuthUser $authUser, LoanOrderRequiredDocs $loanOrderRequiredDocs): bool + { + return $authUser->can('View:LoanOrderRequiredDocs'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:LoanOrderRequiredDocs'); + } + + public function update(AuthUser $authUser, LoanOrderRequiredDocs $loanOrderRequiredDocs): bool + { + return $authUser->can('Update:LoanOrderRequiredDocs'); + } + + public function delete(AuthUser $authUser, LoanOrderRequiredDocs $loanOrderRequiredDocs): bool + { + return $authUser->can('Delete:LoanOrderRequiredDocs'); + } + + public function restore(AuthUser $authUser, LoanOrderRequiredDocs $loanOrderRequiredDocs): bool + { + return $authUser->can('Restore:LoanOrderRequiredDocs'); + } + + public function forceDelete(AuthUser $authUser, LoanOrderRequiredDocs $loanOrderRequiredDocs): bool + { + return $authUser->can('ForceDelete:LoanOrderRequiredDocs'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:LoanOrderRequiredDocs'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:LoanOrderRequiredDocs'); + } + + public function replicate(AuthUser $authUser, LoanOrderRequiredDocs $loanOrderRequiredDocs): bool + { + return $authUser->can('Replicate:LoanOrderRequiredDocs'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:LoanOrderRequiredDocs'); + } + +} \ No newline at end of file diff --git a/app/Modules/LoanOrder/Policies/LoanTypePolicy.php b/app/Modules/LoanOrder/Policies/LoanTypePolicy.php new file mode 100644 index 0000000..b70e03b --- /dev/null +++ b/app/Modules/LoanOrder/Policies/LoanTypePolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:LoanType'); + } + + public function view(AuthUser $authUser, LoanType $loanType): bool + { + return $authUser->can('View:LoanType'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:LoanType'); + } + + public function update(AuthUser $authUser, LoanType $loanType): bool + { + return $authUser->can('Update:LoanType'); + } + + public function delete(AuthUser $authUser, LoanType $loanType): bool + { + return $authUser->can('Delete:LoanType'); + } + + public function restore(AuthUser $authUser, LoanType $loanType): bool + { + return $authUser->can('Restore:LoanType'); + } + + public function forceDelete(AuthUser $authUser, LoanType $loanType): bool + { + return $authUser->can('ForceDelete:LoanType'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:LoanType'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:LoanType'); + } + + public function replicate(AuthUser $authUser, LoanType $loanType): bool + { + return $authUser->can('Replicate:LoanType'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:LoanType'); + } + +} \ No newline at end of file diff --git a/app/Modules/LoanPaidOffLetter/Policies/LoanPaidOffLetterPolicy.php b/app/Modules/LoanPaidOffLetter/Policies/LoanPaidOffLetterPolicy.php new file mode 100644 index 0000000..51f1e7d --- /dev/null +++ b/app/Modules/LoanPaidOffLetter/Policies/LoanPaidOffLetterPolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:LoanPaidOffLetter'); + } + + public function view(AuthUser $authUser, LoanPaidOffLetter $loanPaidOffLetter): bool + { + return $authUser->can('View:LoanPaidOffLetter'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:LoanPaidOffLetter'); + } + + public function update(AuthUser $authUser, LoanPaidOffLetter $loanPaidOffLetter): bool + { + return $authUser->can('Update:LoanPaidOffLetter'); + } + + public function delete(AuthUser $authUser, LoanPaidOffLetter $loanPaidOffLetter): bool + { + return $authUser->can('Delete:LoanPaidOffLetter'); + } + + public function restore(AuthUser $authUser, LoanPaidOffLetter $loanPaidOffLetter): bool + { + return $authUser->can('Restore:LoanPaidOffLetter'); + } + + public function forceDelete(AuthUser $authUser, LoanPaidOffLetter $loanPaidOffLetter): bool + { + return $authUser->can('ForceDelete:LoanPaidOffLetter'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:LoanPaidOffLetter'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:LoanPaidOffLetter'); + } + + public function replicate(AuthUser $authUser, LoanPaidOffLetter $loanPaidOffLetter): bool + { + return $authUser->can('Replicate:LoanPaidOffLetter'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:LoanPaidOffLetter'); + } + +} \ No newline at end of file diff --git a/app/Modules/Province/Policies/ProvincePolicy.php b/app/Modules/Province/Policies/ProvincePolicy.php new file mode 100644 index 0000000..f5a6897 --- /dev/null +++ b/app/Modules/Province/Policies/ProvincePolicy.php @@ -0,0 +1,70 @@ +can('ViewAny:Province'); + } + + public function view(AuthUser $authUser, Province $province): bool + { + return $authUser->can('View:Province'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:Province'); + } + + public function update(AuthUser $authUser, Province $province): bool + { + return $authUser->can('Update:Province'); + } + + public function delete(AuthUser $authUser, Province $province): bool + { + return $authUser->can('Delete:Province'); + } + + public function restore(AuthUser $authUser, Province $province): bool + { + return $authUser->can('Restore:Province'); + } + + public function forceDelete(AuthUser $authUser, Province $province): bool + { + return $authUser->can('ForceDelete:Province'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:Province'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:Province'); + } + + public function replicate(AuthUser $authUser, Province $province): bool + { + return $authUser->can('Replicate:Province'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:Province'); + } + +} \ No newline at end of file diff --git a/app/Policies/RolePolicy.php b/app/Policies/RolePolicy.php index 1654cec..a2a3263 100644 --- a/app/Policies/RolePolicy.php +++ b/app/Policies/RolePolicy.php @@ -4,14 +4,14 @@ declare(strict_types=1); namespace App\Policies; -use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Foundation\Auth\User as AuthUser; use Spatie\Permission\Models\Role; +use Illuminate\Auth\Access\HandlesAuthorization; class RolePolicy { use HandlesAuthorization; - + public function viewAny(AuthUser $authUser): bool { return $authUser->can('ViewAny:Role'); @@ -66,4 +66,5 @@ class RolePolicy { return $authUser->can('Reorder:Role'); } -} + +} \ No newline at end of file diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php new file mode 100644 index 0000000..10cdce3 --- /dev/null +++ b/app/Policies/UserPolicy.php @@ -0,0 +1,67 @@ +can('ViewAny:User'); + } + + public function view(AuthUser $authUser): bool + { + return $authUser->can('View:User'); + } + + public function create(AuthUser $authUser): bool + { + return $authUser->can('Create:User'); + } + + public function update(AuthUser $authUser): bool + { + return $authUser->can('Update:User'); + } + + public function delete(AuthUser $authUser): bool + { + return $authUser->can('Delete:User'); + } + + public function restore(AuthUser $authUser): bool + { + return $authUser->can('Restore:User'); + } + + public function forceDelete(AuthUser $authUser): bool + { + return $authUser->can('ForceDelete:User'); + } + + public function forceDeleteAny(AuthUser $authUser): bool + { + return $authUser->can('ForceDeleteAny:User'); + } + + public function restoreAny(AuthUser $authUser): bool + { + return $authUser->can('RestoreAny:User'); + } + + public function replicate(AuthUser $authUser): bool + { + return $authUser->can('Replicate:User'); + } + + public function reorder(AuthUser $authUser): bool + { + return $authUser->can('Reorder:User'); + } + +} \ No newline at end of file