diff --git a/app/Filament/Resources/Master/Departments/DepartmentResource.php b/app/Filament/Resources/Master/Departments/DepartmentResource.php new file mode 100644 index 0000000..e10343d --- /dev/null +++ b/app/Filament/Resources/Master/Departments/DepartmentResource.php @@ -0,0 +1,145 @@ +components([ + TextInput::make('name') + ->label('Nama') + ->placeholder('Dinas Komunikasi dan Informatika') + ->autocomplete(false) + ->autofocus() + ->required() + ->maxLength(100), + + TextInput::make('alias') + ->placeholder('Diskominfo') + ->autocomplete(false) + ->autofocus() + ->required() + ->maxLength(20), + ]) + ->columns(1); + } + + public static function table(Table $table): Table + { + return $table + ->recordTitleAttribute('name') + ->columns([ + TextColumn::make('name') + ->label('Nama') + ->searchable() + ->sortable(), + + TextColumn::make('alias') + ->searchable() + ->sortable(), + + ToggleColumn::make('is_active') + ->label('Aktif?') + ->getStateUsing(fn (Department $record) => $record->is_active === IsActive::ACTIVE) + ->updateStateUsing(function (Department $record, bool $state) { + $record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE; + $record->save(); + }) + ->sortable(), + + TextColumn::make('created_at') + ->label('Dibuat') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + + TextColumn::make('updated_at') + ->label('Diperbarui') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + + TextColumn::make('deleted_at') + ->label('Dihapus') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + TrashedFilter::make()->native(false), + ]) + ->recordActions([ + EditAction::make()->modalWidth('lg'), + DeleteAction::make(), + ForceDeleteAction::make(), + RestoreAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ForceDeleteBulkAction::make(), + RestoreBulkAction::make(), + ]), + ]) + ->emptyStateIcon('heroicon-o-bookmark') + ->emptyStateDescription('Setelah Anda menulis posting pertama, maka akan muncul disini.') + ->defaultSort('created_at', 'desc') + ->deferFilters(false) + ->reorderable('sort_order'); + } + + public static function getPages(): array + { + return [ + 'index' => ManageDepartments::route('/'), + ]; + } + + public static function getRecordRouteBindingEloquentQuery(): Builder + { + return parent::getRecordRouteBindingEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/Master/Departments/Pages/ManageDepartments.php b/app/Filament/Resources/Master/Departments/Pages/ManageDepartments.php new file mode 100644 index 0000000..385b6e6 --- /dev/null +++ b/app/Filament/Resources/Master/Departments/Pages/ManageDepartments.php @@ -0,0 +1,30 @@ +label('Tambah') + ->modalHeading('Tambah OPD') + ->modalSubmitActionLabel('Simpan') + ->modalCancelActionLabel('Batal') + ->extraModalFooterActions(fn (CreateAction $action): array => [ + $action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) + ->label('Simpan dan Tambah Lagi'), + ]) + ->modalWidth('lg'), + ]; + } +} diff --git a/app/Filament/Resources/Master/Locations/LocationResource.php b/app/Filament/Resources/Master/Locations/LocationResource.php index fccfdba..92809e6 100644 --- a/app/Filament/Resources/Master/Locations/LocationResource.php +++ b/app/Filament/Resources/Master/Locations/LocationResource.php @@ -49,7 +49,7 @@ public static function form(Schema $schema): Schema ->components([ TextInput::make('name') ->label('Nama') - ->placeholder('Pelaporan') + ->placeholder('Purwakarta') ->autocomplete(false) ->autofocus() ->required() diff --git a/app/Filament/Resources/Master/SubClassifications/SubClassificationResource.php b/app/Filament/Resources/Master/SubClassifications/SubClassificationResource.php index 51dd998..0fd1f6c 100644 --- a/app/Filament/Resources/Master/SubClassifications/SubClassificationResource.php +++ b/app/Filament/Resources/Master/SubClassifications/SubClassificationResource.php @@ -59,7 +59,7 @@ public static function form(Schema $schema): Schema TextInput::make('name') ->label('Nama') - ->placeholder('Pengaduan') + ->placeholder('Nagrikaler') ->autocomplete(false) ->autofocus() ->required() diff --git a/app/Models/Department.php b/app/Models/Department.php new file mode 100644 index 0000000..6528083 --- /dev/null +++ b/app/Models/Department.php @@ -0,0 +1,22 @@ + IsActive::class, + 'sort_order' => 'integer', + ]; + } +} diff --git a/database/migrations/2025_11_19_085234_create_departments_table.php b/database/migrations/2025_11_19_085234_create_departments_table.php new file mode 100644 index 0000000..dda0c90 --- /dev/null +++ b/database/migrations/2025_11_19_085234_create_departments_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('name', 100); + $table->string('alias', 20); + $table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); + $table->integer('sort_order')->default(0); + $table->timestamp('created_at')->useCurrent(); + $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('departments'); + } +};