a2ddea2529
- Creates labor_categories table (company-scoped) seeded with 11 defaults - LaborCategory model with BelongsToTenant - Full Filament CRUD resource with drag-to-reorder (sort_order) - LaborResource category Select now reads from DB instead of hardcoded const - Navigation: 'Categorii manopere' in Service group, sort 33 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
98 lines
2.8 KiB
PHP
98 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Resources;
|
|
|
|
use App\Filament\Tenant\Resources\LaborCategoryResource\Pages;
|
|
use App\Models\Tenant\LaborCategory;
|
|
use Filament\Actions;
|
|
use Filament\Forms;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class LaborCategoryResource extends Resource
|
|
{
|
|
protected static ?string $model = LaborCategory::class;
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-tag';
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return __('Categorii manopere');
|
|
}
|
|
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
return __('nav.group.Service');
|
|
}
|
|
|
|
public static function getModelLabel(): string
|
|
{
|
|
return __('categorie');
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return __('Categorii manopere');
|
|
}
|
|
|
|
protected static ?int $navigationSort = 33;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Forms\Components\TextInput::make('name')
|
|
->label(__('Denumire'))
|
|
->required()
|
|
->maxLength(80)
|
|
->columnSpanFull(),
|
|
Forms\Components\TextInput::make('sort_order')
|
|
->label(__('Ordine'))
|
|
->numeric()
|
|
->default(0),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('sort_order')
|
|
->label('#')
|
|
->sortable()
|
|
->alignRight()
|
|
->width(50),
|
|
Tables\Columns\TextColumn::make('name')
|
|
->label(__('Categorie'))
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('updated_at')
|
|
->label(__('Modificat'))
|
|
->dateTime('d.m.Y')
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->defaultSort('sort_order')
|
|
->reorderable('sort_order')
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListLaborCategories::route('/'),
|
|
'create' => Pages\CreateLaborCategory::route('/create'),
|
|
'edit' => Pages\EditLaborCategory::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|