From b5e1e005be7cb1ccba59556a505d2d672c944834 Mon Sep 17 00:00:00 2001 From: annajwasz Date: Wed, 30 Apr 2025 12:23:16 +0700 Subject: [PATCH] add policy --- .env .example | 66 +++++++++++ app/Policies/HasilPolicy.php | 108 ++++++++++++++++++ app/Policies/PengumumanPolicy.php | 108 ++++++++++++++++++ app/Providers/Filament/AdminPanelProvider.php | 3 + database/seeders/DatabaseSeeder.php | 1 + 5 files changed, 286 insertions(+) create mode 100644 .env .example create mode 100644 app/Policies/HasilPolicy.php create mode 100644 app/Policies/PengumumanPolicy.php diff --git a/.env .example b/.env .example new file mode 100644 index 00000000..c5033977 --- /dev/null +++ b/.env .example @@ -0,0 +1,66 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY=base64:YOUR_APP_KEY +APP_DEBUG=true +APP_TIMEZONE=Asia/Jakarta +APP_URL=http://localhost:8000 + +APP_LOCALE=id +APP_FALLBACK_LOCALE=en +APP_FAKER_LOCALE=en_US + +APP_MAINTENANCE_DRIVER=file +# APP_MAINTENANCE_STORE=database + +PHP_CLI_SERVER_WORKERS=4 + +BCRYPT_ROUNDS=12 + +LOG_CHANNEL=stack +LOG_STACK=single +LOG_DEPRECATIONS_CHANNEL=null +LOG_LEVEL=debug + +DB_CONNECTION=mysql +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=your_database +DB_USERNAME=your_username +DB_PASSWORD=your_password + +SESSION_DRIVER=database +SESSION_LIFETIME=120 +SESSION_ENCRYPT=false +SESSION_PATH=/ +SESSION_DOMAIN=null + +BROADCAST_CONNECTION=log +FILESYSTEM_DISK=local +QUEUE_CONNECTION=database + +CACHE_STORE=database +CACHE_PREFIX= + +MEMCACHED_HOST=127.0.0.1 + +REDIS_CLIENT=phpredis +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=log +MAIL_SCHEME=null +MAIL_HOST=127.0.0.1 +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_FROM_ADDRESS="hello@example.com" +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= +AWS_USE_PATH_STYLE_ENDPOINT=false + +VITE_APP_NAME="${APP_NAME}" diff --git a/app/Policies/HasilPolicy.php b/app/Policies/HasilPolicy.php new file mode 100644 index 00000000..427479e0 --- /dev/null +++ b/app/Policies/HasilPolicy.php @@ -0,0 +1,108 @@ +can('view_any_hasil'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Parameter $parameter): bool + { + return $user->can('view_hasil'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->can('create_hasil'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Parameter $parameter): bool + { + return $user->can('update_hasil'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Parameter $parameter): bool + { + return $user->can('delete_hasil'); + } + + /** + * Determine whether the user can bulk delete. + */ + public function deleteAny(User $user): bool + { + return $user->can('delete_any_hasil'); + } + + /** + * Determine whether the user can permanently delete. + */ + public function forceDelete(User $user, Parameter $parameter): bool + { + return $user->can('force_delete_hasil'); + } + + /** + * Determine whether the user can permanently bulk delete. + */ + public function forceDeleteAny(User $user): bool + { + return $user->can('force_delete_any_hasil'); + } + + /** + * Determine whether the user can restore. + */ + public function restore(User $user, Parameter $parameter): bool + { + return $user->can('restore_hasil'); + } + + /** + * Determine whether the user can bulk restore. + */ + public function restoreAny(User $user): bool + { + return $user->can('restore_any_hasil'); + } + + /** + * Determine whether the user can replicate. + */ + public function replicate(User $user, Parameter $parameter): bool + { + return $user->can('replicate_hasil'); + } + + /** + * Determine whether the user can reorder. + */ + public function reorder(User $user): bool + { + return $user->can('reorder_hasil'); + } +} \ No newline at end of file diff --git a/app/Policies/PengumumanPolicy.php b/app/Policies/PengumumanPolicy.php new file mode 100644 index 00000000..e2cb723f --- /dev/null +++ b/app/Policies/PengumumanPolicy.php @@ -0,0 +1,108 @@ +can('view_any_pengumuman'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Parameter $parameter): bool + { + return $user->can('view_pengumuman'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->can('create_pengumuman'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Parameter $parameter): bool + { + return $user->can('update_pengumuman'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Parameter $parameter): bool + { + return $user->can('delete_pengumuman'); + } + + /** + * Determine whether the user can bulk delete. + */ + public function deleteAny(User $user): bool + { + return $user->can('delete_any_pengumuman'); + } + + /** + * Determine whether the user can permanently delete. + */ + public function forceDelete(User $user, Parameter $parameter): bool + { + return $user->can('force_delete_pengumuman'); + } + + /** + * Determine whether the user can permanently bulk delete. + */ + public function forceDeleteAny(User $user): bool + { + return $user->can('force_delete_any_pengumuman'); + } + + /** + * Determine whether the user can restore. + */ + public function restore(User $user, Parameter $parameter): bool + { + return $user->can('restore_pengumuman'); + } + + /** + * Determine whether the user can bulk restore. + */ + public function restoreAny(User $user): bool + { + return $user->can('restore_any_pengumuman'); + } + + /** + * Determine whether the user can replicate. + */ + public function replicate(User $user, Parameter $parameter): bool + { + return $user->can('replicate_pengumuman'); + } + + /** + * Determine whether the user can reorder. + */ + public function reorder(User $user): bool + { + return $user->can('reorder_pengumuman'); + } +} \ No newline at end of file diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 3aa8dad3..2918bb6b 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -61,6 +61,9 @@ public function panel(Panel $panel): Panel ]) ->authMiddleware([ Authenticate::class, + ]) + ->plugins([ + \BezhanSalleh\FilamentShield\FilamentShieldPlugin::make(), ]); } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index ee321f1b..76fe2e03 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -18,6 +18,7 @@ public function run(): void SubKriteriaSeeder::class, MahasiswaSeeder::class, SuperAdminPermissionSeeder::class, + PermissionSeeder::class, ]); } }