diff --git a/app/Filament/Resources/Master/Warehouses/Pages/ManageWarehouses.php b/app/Filament/Resources/Master/Warehouses/Pages/ManageWarehouses.php new file mode 100644 index 0000000..c8b0391 --- /dev/null +++ b/app/Filament/Resources/Master/Warehouses/Pages/ManageWarehouses.php @@ -0,0 +1,31 @@ +label('Tambah') + ->modalHeading('Tambah Gudang') + ->modalSubmitActionLabel('Simpan') + ->modalCancelActionLabel('Batal') + ->extraModalFooterActions(fn (CreateAction $action): array => [ + $action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) + ->label('Simpan dan Tambah Lagi'), + ]) + ->modalWidth(Width::Large), + ]; + } +} diff --git a/app/Filament/Resources/Master/Warehouses/WarehouseResource.php b/app/Filament/Resources/Master/Warehouses/WarehouseResource.php new file mode 100644 index 0000000..a607207 --- /dev/null +++ b/app/Filament/Resources/Master/Warehouses/WarehouseResource.php @@ -0,0 +1,132 @@ +components([ + TextInput::make('name') + ->label('Nama Gudang') + ->placeholder('Gudang Utama') + ->autocomplete(false) + ->required() + ->maxLength(30), + + TextInput::make('location') + ->label('Lokasi') + ->placeholder('Tasikmalaya') + ->autocomplete(false) + ->nullable(), + + Textarea::make('notes') + ->label('Catatan') + ->placeholder('...') + ->nullable() + ->autocomplete(false), + ]) + ->columns(1); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('name') + ->label('Nama Gudang') + ->searchable() + ->sortable(), + + TextColumn::make('location') + ->label('Lokasi') + ->searchable() + ->sortable(), + + TextColumn::make('notes') + ->label('Catatan') + ->searchable() + ->limit(50), + + ...TimestampColumns::make(), + ]) + ->filters([ + TrashedFilter::make() + ->native(false) + ->visible(fn (): bool => auth()->user()->hasRole(RoleEnum::DEVELOPER)), + ]) + ->recordActions([ + EditAction::make() + ->modalWidth(Width::Large), + + DeleteAction::make(), + + ForceDeleteAction::make(), + + RestoreAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + ...DefaultBulkActions::make('Pengeluaran'), + ]), + ]) + ->emptyStateIcon(Heroicon::BuildingOffice2) + ->emptyStateDescription('Setelah Anda membuat data pertama, maka akan muncul disini.') + ->defaultSort('created_at', 'desc') + ->deferFilters(false); + } + + public static function getPages(): array + { + return [ + 'index' => ManageWarehouses::route('/'), + ]; + } + + public static function getRecordRouteBindingEloquentQuery(): Builder + { + return parent::getRecordRouteBindingEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Models/Warehouse.php b/app/Models/Warehouse.php new file mode 100644 index 0000000..2269ef1 --- /dev/null +++ b/app/Models/Warehouse.php @@ -0,0 +1,14 @@ +id(); + $table->string('name', 30); + $table->string('location')->nullable(); + $table->text('notes')->nullable(); + $table->timestamp('created_at')->useCurrent(); + $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); + $table->softDeletes(); + }); + } + + public function down(): void + { + Schema::dropIfExists('warehouses'); + } +};