navigation roles uda ada

This commit is contained in:
annajwasz 2025-04-16 13:21:31 +07:00
parent 54dc34b7b1
commit ee4b4c2404
24 changed files with 578 additions and 108 deletions

View File

@ -3,10 +3,21 @@
namespace App\Filament\Pages\Auth;
use Filament\Pages\Auth\Register as BaseRegister;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
class Register extends BaseRegister
{
// Kustomisasi form registrasi jika diperlukan
public ?array $data = [];
protected function handleRegistration(array $data): Model
{
$user = parent::handleRegistration($data);
$user->assignRole('mahasiswa');
return $user;
}
protected function getForms(): array
{
return [

View File

@ -32,16 +32,11 @@ public static function form(Form $form): Form
return $form
->schema([
TextInput::make('nama')
->required()
->label('Nama Kriteria'),
->required(),//kolom wajib diisi
TextInput::make('prioritas')
->numeric()
->required()
->label('Prioritas (Urutan)')
->helperText('Masukkan angka prioritas (1 untuk prioritas tertinggi)'),
->required(),
TextInput::make('bobot')
->disabled()
->helperText('Bobot akan dihitung otomatis menggunakan metode SMARTER'),
// ->required(),
]);
}
@ -50,19 +45,14 @@ public static function table(Table $table): Table
return $table
->columns([
TextColumn::make('nama')
->label('Nama Kriteria')
->searchable()
->sortable(),
TextColumn::make('prioritas')
->label('Prioritas')
->sortable(),
TextColumn::make('bobot')
->label('Bobot')
->formatStateUsing(fn ($state) => number_format($state, 4))
->sortable(),
->searchable(),
TextColumn::make('prioritas'),
TextColumn::make('bobot'),
])
->filters([
//
])
->defaultSort('prioritas')
->filters([])
->actions([
Tables\Actions\EditAction::make(),
])

View File

@ -30,10 +30,7 @@ class ParameterResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-clipboard-document-list';
protected static ?string $navigationLabel = 'Perangkingan';
protected static ?string $modelLabel = 'Perangkingan';
protected static ?string $pluralModelLabel = 'Perangkingan';
protected static ?string $breadcrumb = 'Perangkingan';
protected static ?string $navigationLabel = 'Form Penilaian KIP-K';
protected static ?string $navigationGroup = 'Penilaian';
@ -301,6 +298,16 @@ public static function table(Table $table): Table
->label('Total Nilai')
->sortable(),
Tables\Columns\TextColumn::make('hasil')
->label('Hasil')
->badge()
->color(fn (string $state): string => match ($state) {
'Layak' => 'success',
'Dipertimbangkan' => 'warning',
'Tidak Layak' => 'danger',
default => 'gray',
}),
Tables\Columns\TextColumn::make('status')
->label('Status Validasi')
->badge()

View File

@ -52,12 +52,10 @@ public static function form(Form $form): Form
->required(),
TextInput::make('prioritas')
->numeric()
->required()
->label('Prioritas (Urutan)')
->helperText('Masukkan angka prioritas (1 untuk prioritas tertinggi)'),
->required(),
TextInput::make('bobot')
->disabled()
->helperText('Bobot akan dihitung otomatis menggunakan metode SMARTER'),
->numeric()
// ->required(),
]);
}
@ -77,14 +75,10 @@ public static function table(Table $table): Table
->sortable()
->searchable(),
TextColumn::make('prioritas')
->label('Prioritas')
->sortable(),
TextColumn::make('bobot')
->label('Bobot')
->formatStateUsing(fn ($state) => number_format($state, 4))
->sortable(),
])
->defaultSort('kriteria_id', 'prioritas')
->filters([
//
])

View File

@ -14,6 +14,7 @@
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\Select;
class UserResource extends Resource
{
@ -44,7 +45,12 @@ public static function form(Form $form): Form
TextInput::make('password')
->password()
->required()
// ->hiddenOn('edit'),
->hiddenOn('edit'),
Select::make('roles')
->multiple()
->relationship('roles', 'name')
->preload()
->helperText('Biarkan kosong untuk role default (mahasiswa)'),
]);
}
@ -58,6 +64,9 @@ public static function table(Table $table): Table
TextColumn::make('email')
->searchable()
->sortable(),
TextColumn::make('roles.name')
->badge()
->color('primary'),
TextColumn::make('password'),
TextColumn::make('created_at')
->dateTime()

View File

@ -6,11 +6,12 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
use HasFactory, Notifiable, HasRoles;
/**
* The attributes that are mass assignable.

108
app/Policies/RolePolicy.php Normal file
View File

@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use Spatie\Permission\Models\Role;
use Illuminate\Auth\Access\HandlesAuthorization;
class RolePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_role');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Role $role): bool
{
return $user->can('view_role');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_role');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Role $role): bool
{
return $user->can('update_role');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Role $role): bool
{
return $user->can('delete_role');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_role');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Role $role): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Role $role): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Role $role): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Policies;
use App\Models\User;
class UserPolicy
{
public function viewAny(User $user): bool
{
return $user->hasRole(['admin', 'super_admin']);
}
public function view(User $user, User $model): bool
{
return $user->hasRole(['admin', 'super_admin']);
}
public function create(User $user): bool
{
return $user->hasRole(['admin', 'super_admin']);
}
public function update(User $user, User $model): bool
{
return $user->hasRole(['admin', 'super_admin']);
}
public function delete(User $user, User $model): bool
{
return $user->hasRole(['admin', 'super_admin']);
}
}

View File

@ -2,6 +2,7 @@
namespace App\Providers\Filament;
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\AuthenticateSession;
use Filament\Http\Middleware\DisableBladeIconComponents;
@ -29,24 +30,20 @@ public function panel(Panel $panel): Panel
->id('admin')
->path('admin')
->login()
->registration()
// ->brandName('POLIJE')
->plugin(FilamentShieldPlugin::make())
->brandLogo(asset('images/logo-polije.png'))
->brandLogoHeight('3rem')
->colors([
// 'primary' => Color::Amber,
'primary' => Color::Blue,
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
// Pages\Dashboard::class,
WizardForm::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
CustomAccountWidget::class,
// Widgets\FilamentInfoWidget::class,
])
->spa()
->middleware([

View File

@ -7,12 +7,15 @@
"license": "MIT",
"require": {
"php": "^8.2",
"bezhansalleh/filament-shield": "^3.3",
"filament/filament": "^3.2",
"laravel/framework": "^11.31",
"laravel/tinker": "^2.9"
"laravel/tinker": "^2.9",
"spatie/laravel-permission": "*"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/breeze": "*",
"laravel/pail": "^1.1",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",

233
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0cefc8f8c8f7320e732db22110e017ed",
"content-hash": "b7799fc8d95c29ec920219812daf4b93",
"packages": [
{
"name": "anourvalar/eloquent-serialize",
@ -72,6 +72,93 @@
},
"time": "2025-02-25T05:18:46+00:00"
},
{
"name": "bezhansalleh/filament-shield",
"version": "3.3.5",
"source": {
"type": "git",
"url": "https://github.com/bezhanSalleh/filament-shield.git",
"reference": "88b6714e4d14abcb614ff3ac45114866763d1ba5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bezhanSalleh/filament-shield/zipball/88b6714e4d14abcb614ff3ac45114866763d1ba5",
"reference": "88b6714e4d14abcb614ff3ac45114866763d1ba5",
"shasum": ""
},
"require": {
"filament/filament": "^3.2",
"php": "^8.1",
"spatie/laravel-package-tools": "^1.9",
"spatie/laravel-permission": "^6.0"
},
"require-dev": {
"larastan/larastan": "^2.0",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0|^8.0",
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.3",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ray": "^1.37"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"FilamentShield": "BezhanSalleh\\FilamentShield\\Facades\\FilamentShield"
},
"providers": [
"BezhanSalleh\\FilamentShield\\FilamentShieldServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"BezhanSalleh\\FilamentShield\\": "src",
"BezhanSalleh\\FilamentShield\\Database\\Factories\\": "database/factories"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bezhan Salleh",
"email": "bezhan_salleh@yahoo.com",
"role": "Developer"
}
],
"description": "Filament support for `spatie/laravel-permission`.",
"homepage": "https://github.com/bezhansalleh/filament-shield",
"keywords": [
"acl",
"bezhanSalleh",
"filament",
"filament-shield",
"laravel",
"permission",
"permissions",
"rbac",
"roles",
"security"
],
"support": {
"issues": "https://github.com/bezhanSalleh/filament-shield/issues",
"source": "https://github.com/bezhanSalleh/filament-shield/tree/3.3.5"
},
"funding": [
{
"url": "https://github.com/bezhanSalleh",
"type": "github"
}
],
"time": "2025-02-17T21:06:24+00:00"
},
{
"name": "blade-ui-kit/blade-heroicons",
"version": "2.6.0",
@ -4885,6 +4972,89 @@
],
"time": "2025-02-06T14:58:20+00:00"
},
{
"name": "spatie/laravel-permission",
"version": "6.17.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-permission.git",
"reference": "02ada8f638b643713fa2fb543384738e27346ddb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/02ada8f638b643713fa2fb543384738e27346ddb",
"reference": "02ada8f638b643713fa2fb543384738e27346ddb",
"shasum": ""
},
"require": {
"illuminate/auth": "^8.12|^9.0|^10.0|^11.0|^12.0",
"illuminate/container": "^8.12|^9.0|^10.0|^11.0|^12.0",
"illuminate/contracts": "^8.12|^9.0|^10.0|^11.0|^12.0",
"illuminate/database": "^8.12|^9.0|^10.0|^11.0|^12.0",
"php": "^8.0"
},
"require-dev": {
"laravel/passport": "^11.0|^12.0",
"laravel/pint": "^1.0",
"orchestra/testbench": "^6.23|^7.0|^8.0|^9.0|^10.0",
"phpunit/phpunit": "^9.4|^10.1|^11.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\Permission\\PermissionServiceProvider"
]
},
"branch-alias": {
"dev-main": "6.x-dev",
"dev-master": "6.x-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Spatie\\Permission\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Permission handling for Laravel 8.0 and up",
"homepage": "https://github.com/spatie/laravel-permission",
"keywords": [
"acl",
"laravel",
"permission",
"permissions",
"rbac",
"roles",
"security",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-permission/issues",
"source": "https://github.com/spatie/laravel-permission/tree/6.17.0"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2025-04-08T15:06:14+00:00"
},
{
"name": "symfony/clock",
"version": "v7.2.0",
@ -7640,6 +7810,67 @@
},
"time": "2020-07-09T08:09:16+00:00"
},
{
"name": "laravel/breeze",
"version": "v2.3.6",
"source": {
"type": "git",
"url": "https://github.com/laravel/breeze.git",
"reference": "390cbc433cb72fa6050965000b2d56c9ba6fd713"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/breeze/zipball/390cbc433cb72fa6050965000b2d56c9ba6fd713",
"reference": "390cbc433cb72fa6050965000b2d56c9ba6fd713",
"shasum": ""
},
"require": {
"illuminate/console": "^11.0|^12.0",
"illuminate/filesystem": "^11.0|^12.0",
"illuminate/support": "^11.0|^12.0",
"illuminate/validation": "^11.0|^12.0",
"php": "^8.2.0",
"symfony/console": "^7.0"
},
"require-dev": {
"laravel/framework": "^11.0|^12.0",
"orchestra/testbench-core": "^9.0|^10.0",
"phpstan/phpstan": "^2.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Laravel\\Breeze\\BreezeServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Breeze\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Minimal Laravel authentication scaffolding with Blade and Tailwind.",
"keywords": [
"auth",
"laravel"
],
"support": {
"issues": "https://github.com/laravel/breeze/issues",
"source": "https://github.com/laravel/breeze"
},
"time": "2025-03-06T14:02:32+00:00"
},
{
"name": "laravel/pail",
"version": "v1.2.2",

View File

@ -0,0 +1,91 @@
<?php
return [
'shield_resource' => [
'should_register_navigation' => true,
'slug' => 'shield/roles',
'navigation_sort' => -1,
'navigation_badge' => true,
'navigation_group' => true,
'is_globally_searchable' => false,
'show_model_path' => true,
'is_scoped_to_tenant' => true,
'cluster' => null,
],
'tenant_model' => null,
'auth_provider_model' => [
'fqcn' => 'App\\Models\\User',
],
'super_admin' => [
'enabled' => true,
'name' => 'super_admin',
'define_via_gate' => false,
'intercept_gate' => 'before', // after
],
'panel_user' => [
'enabled' => true,
'name' => 'panel_user',
],
'permission_prefixes' => [
'resource' => [
'view',
'view_any',
'create',
'update',
'restore',
'restore_any',
'replicate',
'reorder',
'delete',
'delete_any',
'force_delete',
'force_delete_any',
],
'page' => 'page',
'widget' => 'widget',
],
'entities' => [
'pages' => true,
'widgets' => true,
'resources' => true,
'custom_permissions' => false,
],
'generator' => [
'option' => 'policies_and_permissions',
'policy_directory' => 'Policies',
'policy_namespace' => 'Policies',
],
'exclude' => [
'enabled' => true,
'pages' => [
'Dashboard',
],
'widgets' => [
'AccountWidget', 'FilamentInfoWidget',
],
'resources' => [],
],
'discovery' => [
'discover_all_resources' => false,
'discover_all_widgets' => false,
'discover_all_pages' => false,
],
'register_role_policy' => [
'enabled' => true,
],
];

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
function i({state:a,splitKeys:n}){return{newTag:"",state:a,createTag:function(){if(this.newTag=this.newTag.trim(),this.newTag!==""){if(this.state.includes(this.newTag)){this.newTag="";return}this.state.push(this.newTag),this.newTag=""}},deleteTag:function(t){this.state=this.state.filter(e=>e!==t)},reorderTags:function(t){let e=this.state.splice(t.oldIndex,1)[0];this.state.splice(t.newIndex,0,e),this.state=[...this.state]},input:{["x-on:blur"]:"createTag()",["x-model"]:"newTag",["x-on:keydown"](t){["Enter",...n].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this.createTag())},["x-on:paste"](){this.$nextTick(()=>{if(n.length===0){this.createTag();return}let t=n.map(e=>e.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&")).join("|");this.newTag.split(new RegExp(t,"g")).forEach(e=>{this.newTag=e,this.createTag()})})}}}}export{i as default};
function i({state:a,splitKeys:n}){return{newTag:"",state:a,createTag:function(){if(this.newTag=this.newTag.trim(),this.newTag!==""){if(this.state.includes(this.newTag)){this.newTag="";return}this.state.push(this.newTag),this.newTag=""}},deleteTag:function(t){this.state=this.state.filter(e=>e!==t)},reorderTags:function(t){let e=this.state.splice(t.oldIndex,1)[0];this.state.splice(t.newIndex,0,e),this.state=[...this.state]},input:{"x-on:blur":"createTag()","x-model":"newTag","x-on:keydown"(t){["Enter",...n].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this.createTag())},"x-on:paste"(){this.$nextTick(()=>{if(n.length===0){this.createTag();return}let t=n.map(e=>e.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&")).join("|");this.newTag.split(new RegExp(t,"g")).forEach(e=>{this.newTag=e,this.createTag()})})}}}}export{i as default};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,6 @@
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Storage;
use App\Http\Controllers\PdfViewController;
use App\Http\Controllers\PengumumanController;
Route::get('/', function () {
return view('welcome');
@ -24,7 +23,3 @@
'Content-Disposition' => 'inline; filename="' . basename($path) . '"'
]);
})->where('path', '.*');
Route::middleware(['auth'])->group(function () {
Route::get('/pengumuman', [PengumumanController::class, 'show'])->name('pengumuman');
});