From 7fd2810278c92d6fd400b671dc40d86469091c82 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 23 Apr 2025 14:42:33 +0530 Subject: [PATCH] Added and updated policy --- app/Policies/BlockPolicy.php | 12 +- app/Policies/CompanyPolicy.php | 106 ++++++++++++++++++ app/Policies/InvoiceValidationPolicy.php | 106 ++++++++++++++++++ app/Policies/ItemPolicy.php | 106 ++++++++++++++++++ app/Policies/LinePolicy.php | 106 ++++++++++++++++++ app/Policies/LineStopPolicy.php | 106 ++++++++++++++++++ app/Policies/PermissionPolicy.php | 80 +++++++++++++ app/Policies/PlantPolicy.php | 106 ++++++++++++++++++ app/Policies/ProductionLineStopPolicy.php | 106 ++++++++++++++++++ app/Policies/ProductionPlanPolicy.php | 106 ++++++++++++++++++ app/Policies/ProductionQuantityPolicy.php | 106 ++++++++++++++++++ app/Policies/QualityValidationPolicy.php | 106 ++++++++++++++++++ app/Policies/RolePolicy.php | 79 +++++++++++++ app/Policies/ShiftPolicy.php | 106 ++++++++++++++++++ app/Policies/StickerMasterPolicy.php | 106 ++++++++++++++++++ app/Policies/UserPolicy.php | 106 ++++++++++++++++++ app/Providers/AppServiceProvider.php | 17 ++- app/Providers/Filament/AdminPanelProvider.php | 10 +- 18 files changed, 1567 insertions(+), 9 deletions(-) create mode 100644 app/Policies/CompanyPolicy.php create mode 100644 app/Policies/InvoiceValidationPolicy.php create mode 100644 app/Policies/ItemPolicy.php create mode 100644 app/Policies/LinePolicy.php create mode 100644 app/Policies/LineStopPolicy.php create mode 100644 app/Policies/PermissionPolicy.php create mode 100644 app/Policies/PlantPolicy.php create mode 100644 app/Policies/ProductionLineStopPolicy.php create mode 100644 app/Policies/ProductionPlanPolicy.php create mode 100644 app/Policies/ProductionQuantityPolicy.php create mode 100644 app/Policies/QualityValidationPolicy.php create mode 100644 app/Policies/RolePolicy.php create mode 100644 app/Policies/ShiftPolicy.php create mode 100644 app/Policies/StickerMasterPolicy.php create mode 100644 app/Policies/UserPolicy.php diff --git a/app/Policies/BlockPolicy.php b/app/Policies/BlockPolicy.php index 332e2f9..92e8019 100644 --- a/app/Policies/BlockPolicy.php +++ b/app/Policies/BlockPolicy.php @@ -36,7 +36,8 @@ class BlockPolicy */ public function update(User $user, Block $block): bool { - return false; + return $user->hasPermissionTo('update Block'); + // return false; } /** @@ -44,7 +45,8 @@ class BlockPolicy */ public function delete(User $user, Block $block): bool { - return false; + return $user->hasPermissionTo('delete Block'); + // return false; } /** @@ -52,7 +54,8 @@ class BlockPolicy */ public function restore(User $user, Block $block): bool { - return false; + return $user->hasPermissionTo('restore Block'); + // return false; } /** @@ -60,6 +63,7 @@ class BlockPolicy */ public function forceDelete(User $user, Block $block): bool { - return false; + return $user->hasPermissionTo('force delete Block'); + // return false; } } diff --git a/app/Policies/CompanyPolicy.php b/app/Policies/CompanyPolicy.php new file mode 100644 index 0000000..2fa1a4c --- /dev/null +++ b/app/Policies/CompanyPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any Company'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Company $company): bool + { + return $user->checkPermissionTo('view Company'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create Company'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Company $company): bool + { + return $user->checkPermissionTo('update Company'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Company $company): bool + { + return $user->checkPermissionTo('delete Company'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any Company'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Company $company): bool + { + return $user->checkPermissionTo('restore Company'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any Company'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, Company $company): bool + { + return $user->checkPermissionTo('replicate Company'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder Company'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Company $company): bool + { + return $user->checkPermissionTo('force-delete Company'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any Company'); + } +} diff --git a/app/Policies/InvoiceValidationPolicy.php b/app/Policies/InvoiceValidationPolicy.php new file mode 100644 index 0000000..5591f20 --- /dev/null +++ b/app/Policies/InvoiceValidationPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any InvoiceValidation'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, InvoiceValidation $invoicevalidation): bool + { + return $user->checkPermissionTo('view InvoiceValidation'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create InvoiceValidation'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, InvoiceValidation $invoicevalidation): bool + { + return $user->checkPermissionTo('update InvoiceValidation'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, InvoiceValidation $invoicevalidation): bool + { + return $user->checkPermissionTo('delete InvoiceValidation'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any InvoiceValidation'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, InvoiceValidation $invoicevalidation): bool + { + return $user->checkPermissionTo('restore InvoiceValidation'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any InvoiceValidation'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, InvoiceValidation $invoicevalidation): bool + { + return $user->checkPermissionTo('replicate InvoiceValidation'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder InvoiceValidation'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, InvoiceValidation $invoicevalidation): bool + { + return $user->checkPermissionTo('force-delete InvoiceValidation'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any InvoiceValidation'); + } +} diff --git a/app/Policies/ItemPolicy.php b/app/Policies/ItemPolicy.php new file mode 100644 index 0000000..026933f --- /dev/null +++ b/app/Policies/ItemPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any Item'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Item $item): bool + { + return $user->checkPermissionTo('view Item'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create Item'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Item $item): bool + { + return $user->checkPermissionTo('update Item'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Item $item): bool + { + return $user->checkPermissionTo('delete Item'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any Item'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Item $item): bool + { + return $user->checkPermissionTo('restore Item'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any Item'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, Item $item): bool + { + return $user->checkPermissionTo('replicate Item'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder Item'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Item $item): bool + { + return $user->checkPermissionTo('force-delete Item'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any Item'); + } +} diff --git a/app/Policies/LinePolicy.php b/app/Policies/LinePolicy.php new file mode 100644 index 0000000..3e517dc --- /dev/null +++ b/app/Policies/LinePolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any Line'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Line $line): bool + { + return $user->checkPermissionTo('view Line'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create Line'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Line $line): bool + { + return $user->checkPermissionTo('update Line'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Line $line): bool + { + return $user->checkPermissionTo('delete Line'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any Line'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Line $line): bool + { + return $user->checkPermissionTo('restore Line'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any Line'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, Line $line): bool + { + return $user->checkPermissionTo('replicate Line'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder Line'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Line $line): bool + { + return $user->checkPermissionTo('force-delete Line'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any Line'); + } +} diff --git a/app/Policies/LineStopPolicy.php b/app/Policies/LineStopPolicy.php new file mode 100644 index 0000000..b05204b --- /dev/null +++ b/app/Policies/LineStopPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any LineStop'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, LineStop $linestop): bool + { + return $user->checkPermissionTo('view LineStop'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create LineStop'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, LineStop $linestop): bool + { + return $user->checkPermissionTo('update LineStop'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, LineStop $linestop): bool + { + return $user->checkPermissionTo('delete LineStop'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any LineStop'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, LineStop $linestop): bool + { + return $user->checkPermissionTo('restore LineStop'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any LineStop'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, LineStop $linestop): bool + { + return $user->checkPermissionTo('replicate LineStop'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder LineStop'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, LineStop $linestop): bool + { + return $user->checkPermissionTo('force-delete LineStop'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any LineStop'); + } +} diff --git a/app/Policies/PermissionPolicy.php b/app/Policies/PermissionPolicy.php new file mode 100644 index 0000000..68ed476 --- /dev/null +++ b/app/Policies/PermissionPolicy.php @@ -0,0 +1,80 @@ +hasPermissionTo('view permissions'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Permission $permission): bool + // public function view(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool + { + return $user->hasPermissionTo('view permissions'); + // return false; + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->hasPermissionTo('create permissions'); + // return false; + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Permission $permission): bool + // public function update(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool + { + return $user->hasPermissionTo('edit permissions'); + // return false; + } + + /** + * Determine whether the user can delete the model. + */ + //public function delete(User $user, Permission $permission): bool + public function delete(User $user, Permission $permission): bool + // public function delete(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool + { + return $user->hasPermissionTo('delete permissions'); + // return false; + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Permission $permission): bool + // public function restore(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool + { + return $user->hasPermissionTo('restore permissions'); + // return false; + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Permission $permission): bool + // public function forceDelete(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool + { + return $user->hasPermissionTo('force-delete permissions'); + // return false; + } +} diff --git a/app/Policies/PlantPolicy.php b/app/Policies/PlantPolicy.php new file mode 100644 index 0000000..d4f1edb --- /dev/null +++ b/app/Policies/PlantPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any Plant'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Plant $plant): bool + { + return $user->checkPermissionTo('view Plant'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create Plant'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Plant $plant): bool + { + return $user->checkPermissionTo('update Plant'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Plant $plant): bool + { + return $user->checkPermissionTo('delete Plant'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any Plant'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Plant $plant): bool + { + return $user->checkPermissionTo('restore Plant'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any Plant'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, Plant $plant): bool + { + return $user->checkPermissionTo('replicate Plant'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder Plant'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Plant $plant): bool + { + return $user->checkPermissionTo('force-delete Plant'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any Plant'); + } +} diff --git a/app/Policies/ProductionLineStopPolicy.php b/app/Policies/ProductionLineStopPolicy.php new file mode 100644 index 0000000..024d4ed --- /dev/null +++ b/app/Policies/ProductionLineStopPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any ProductionLineStop'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, ProductionLineStop $productionlinestop): bool + { + return $user->checkPermissionTo('view ProductionLineStop'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create ProductionLineStop'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, ProductionLineStop $productionlinestop): bool + { + return $user->checkPermissionTo('update ProductionLineStop'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, ProductionLineStop $productionlinestop): bool + { + return $user->checkPermissionTo('delete ProductionLineStop'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any ProductionLineStop'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, ProductionLineStop $productionlinestop): bool + { + return $user->checkPermissionTo('restore ProductionLineStop'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any ProductionLineStop'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, ProductionLineStop $productionlinestop): bool + { + return $user->checkPermissionTo('replicate ProductionLineStop'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder ProductionLineStop'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, ProductionLineStop $productionlinestop): bool + { + return $user->checkPermissionTo('force-delete ProductionLineStop'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any ProductionLineStop'); + } +} diff --git a/app/Policies/ProductionPlanPolicy.php b/app/Policies/ProductionPlanPolicy.php new file mode 100644 index 0000000..219ab86 --- /dev/null +++ b/app/Policies/ProductionPlanPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any ProductionPlan'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, ProductionPlan $productionplan): bool + { + return $user->checkPermissionTo('view ProductionPlan'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create ProductionPlan'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, ProductionPlan $productionplan): bool + { + return $user->checkPermissionTo('update ProductionPlan'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, ProductionPlan $productionplan): bool + { + return $user->checkPermissionTo('delete ProductionPlan'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any ProductionPlan'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, ProductionPlan $productionplan): bool + { + return $user->checkPermissionTo('restore ProductionPlan'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any ProductionPlan'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, ProductionPlan $productionplan): bool + { + return $user->checkPermissionTo('replicate ProductionPlan'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder ProductionPlan'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, ProductionPlan $productionplan): bool + { + return $user->checkPermissionTo('force-delete ProductionPlan'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any ProductionPlan'); + } +} diff --git a/app/Policies/ProductionQuantityPolicy.php b/app/Policies/ProductionQuantityPolicy.php new file mode 100644 index 0000000..877b67d --- /dev/null +++ b/app/Policies/ProductionQuantityPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any ProductionQuantity'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, ProductionQuantity $productionquantity): bool + { + return $user->checkPermissionTo('view ProductionQuantity'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create ProductionQuantity'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, ProductionQuantity $productionquantity): bool + { + return $user->checkPermissionTo('update ProductionQuantity'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, ProductionQuantity $productionquantity): bool + { + return $user->checkPermissionTo('delete ProductionQuantity'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any ProductionQuantity'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, ProductionQuantity $productionquantity): bool + { + return $user->checkPermissionTo('restore ProductionQuantity'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any ProductionQuantity'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, ProductionQuantity $productionquantity): bool + { + return $user->checkPermissionTo('replicate ProductionQuantity'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder ProductionQuantity'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, ProductionQuantity $productionquantity): bool + { + return $user->checkPermissionTo('force-delete ProductionQuantity'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any ProductionQuantity'); + } +} diff --git a/app/Policies/QualityValidationPolicy.php b/app/Policies/QualityValidationPolicy.php new file mode 100644 index 0000000..83e7606 --- /dev/null +++ b/app/Policies/QualityValidationPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any QualityValidation'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, QualityValidation $qualityvalidation): bool + { + return $user->checkPermissionTo('view QualityValidation'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create QualityValidation'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, QualityValidation $qualityvalidation): bool + { + return $user->checkPermissionTo('update QualityValidation'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, QualityValidation $qualityvalidation): bool + { + return $user->checkPermissionTo('delete QualityValidation'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any QualityValidation'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, QualityValidation $qualityvalidation): bool + { + return $user->checkPermissionTo('restore QualityValidation'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any QualityValidation'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, QualityValidation $qualityvalidation): bool + { + return $user->checkPermissionTo('replicate QualityValidation'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder QualityValidation'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, QualityValidation $qualityvalidation): bool + { + return $user->checkPermissionTo('force-delete QualityValidation'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any QualityValidation'); + } +} diff --git a/app/Policies/RolePolicy.php b/app/Policies/RolePolicy.php new file mode 100644 index 0000000..cc86428 --- /dev/null +++ b/app/Policies/RolePolicy.php @@ -0,0 +1,79 @@ +hasPermissionTo('view roles'); + // return false; + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Role $role): bool // Changed typehint + // public function view(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool + { + return $user->hasPermissionTo('view roles'); + // return false; + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->hasPermissionTo('create roles'); + // return false; + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Role $role): bool // Changed typehint + // public function update(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool + { + return $user->hasPermissionTo('edit roles'); + // return false; + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Role $role): bool // Changed typehint + // public function delete(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool + { + return $user->hasPermissionTo('delete roles'); + // return false; + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Role $role): bool // Changed typehint + // public function restore(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool + { + return $user->hasPermissionTo('restore roles'); + // return false; + } + + /** + * Determine whether the user can permanently delete the model. + */ + // public function forceDelete(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool + public function forceDelete(User $user, Role $role): bool // Changed typehint + { + return $user->hasPermissionTo('force-delete roles'); + // return false; + } +} diff --git a/app/Policies/ShiftPolicy.php b/app/Policies/ShiftPolicy.php new file mode 100644 index 0000000..d6ed9f8 --- /dev/null +++ b/app/Policies/ShiftPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any Shift'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Shift $shift): bool + { + return $user->checkPermissionTo('view Shift'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create Shift'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Shift $shift): bool + { + return $user->checkPermissionTo('update Shift'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Shift $shift): bool + { + return $user->checkPermissionTo('delete Shift'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any Shift'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Shift $shift): bool + { + return $user->checkPermissionTo('restore Shift'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any Shift'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, Shift $shift): bool + { + return $user->checkPermissionTo('replicate Shift'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder Shift'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Shift $shift): bool + { + return $user->checkPermissionTo('force-delete Shift'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any Shift'); + } +} diff --git a/app/Policies/StickerMasterPolicy.php b/app/Policies/StickerMasterPolicy.php new file mode 100644 index 0000000..31066ba --- /dev/null +++ b/app/Policies/StickerMasterPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any StickerMaster'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, StickerMaster $stickermaster): bool + { + return $user->checkPermissionTo('view StickerMaster'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create StickerMaster'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, StickerMaster $stickermaster): bool + { + return $user->checkPermissionTo('update StickerMaster'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, StickerMaster $stickermaster): bool + { + return $user->checkPermissionTo('delete StickerMaster'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any StickerMaster'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, StickerMaster $stickermaster): bool + { + return $user->checkPermissionTo('restore StickerMaster'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any StickerMaster'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, StickerMaster $stickermaster): bool + { + return $user->checkPermissionTo('replicate StickerMaster'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder StickerMaster'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, StickerMaster $stickermaster): bool + { + return $user->checkPermissionTo('force-delete StickerMaster'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any StickerMaster'); + } +} diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php new file mode 100644 index 0000000..b3bc4a2 --- /dev/null +++ b/app/Policies/UserPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any User'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, User $model): bool + { + return $user->checkPermissionTo('view User'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create User'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, User $model): bool + { + return $user->checkPermissionTo('update User'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, User $model): bool + { + return $user->checkPermissionTo('delete User'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any User'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, User $model): bool + { + return $user->checkPermissionTo('restore User'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any User'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, User $model): bool + { + return $user->checkPermissionTo('replicate User'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder User'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, User $model): bool + { + return $user->checkPermissionTo('force-delete User'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any User'); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 896ecfb..21eb680 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,9 +2,13 @@ namespace App\Providers; +use App\Models\User; use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; -use URL; +use App\Policies\RolePolicy; +use App\Policies\PermissionPolicy; +use Spatie\Permission\Models\Role; +use Spatie\Permission\Models\Permission; // use Doctrine\DBAL\Types\Type; @@ -23,8 +27,12 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - Gate::before(function ($user, $ability) { - return $user->hasRole('Super Admin') ? true : null; + // Gate::before(function ($user, $ability) { + // return $user->hasRole('Super Admin') ? true : null; + // }); + + Gate::before(function (User $user, string $ability) { + return $user->isSuperAdmin() ? true: null; }); // URL::forceScheme('https'); @@ -32,5 +40,8 @@ class AppServiceProvider extends ServiceProvider // if (!Type::hasType('citext')) { // Type::addType('citext', \Doctrine\DBAL\Platforms\PostgreSqlPlatform::class); // } + + Gate::policy(Role::class, RolePolicy::class); + Gate::policy(Permission::class, PermissionPolicy::class); } } diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index b9f5b43..edde0a1 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -3,12 +3,15 @@ namespace App\Providers\Filament; use Althinect\FilamentSpatieRolesPermissions\FilamentSpatieRolesPermissionsPlugin; +use App\Filament\Pages\InvoiceDashboard; +use Filament\Facades\Filament; use Filament\Http\Middleware\Authenticate; use Filament\Http\Middleware\AuthenticateSession; use Filament\Http\Middleware\DisableBladeIconComponents; use Filament\Http\Middleware\DispatchServingFilamentEvent; use Filament\Navigation\MenuItem; use Filament\Navigation\NavigationGroup; +use Filament\Navigation\NavigationItem; use Filament\Pages; use Filament\Panel; use Filament\PanelProvider; @@ -20,6 +23,7 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken; use Illuminate\Routing\Middleware\SubstituteBindings; use Illuminate\Session\Middleware\StartSession; use Illuminate\View\Middleware\ShareErrorsFromSession; +use Althinect\FilamentSpatieRolesPermissions\Middleware\SyncSpatiePermissionsWithFilamentTenants; class AdminPanelProvider extends PanelProvider { @@ -27,7 +31,6 @@ class AdminPanelProvider extends PanelProvider { return $panel ->default() - ->id('admin') ->path('admin') ->login() @@ -38,9 +41,9 @@ class AdminPanelProvider extends PanelProvider ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') ->pages([ - ]) + ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') // ->widgets([ // Widgets\AccountWidget::class, @@ -60,6 +63,9 @@ class AdminPanelProvider extends PanelProvider ->authMiddleware([ Authenticate::class, ]) + ->tenantMiddleware([ + SyncSpatiePermissionsWithFilamentTenants::class, + ], isPersistent: true) ->databaseNotifications() ->plugin(FilamentSpatieRolesPermissionsPlugin::make()); }