89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\DepartmentResource\Pages;
|
|
use App\Models\Department;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
class DepartmentResource extends Resource
|
|
{
|
|
protected static ?string $model = Department::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-building-storefront';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
TextInput::make('guid')
|
|
->required()
|
|
->maxLength(40)
|
|
->default(sprintf('FAC-%s', Uuid::uuid4())),
|
|
Toggle::make('is_active')
|
|
->required(),
|
|
Select::make('organization_id')
|
|
->relationship('organization', 'name')
|
|
->required(),
|
|
TextInput::make('name')
|
|
->required()
|
|
->maxLength(255),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
IconColumn::make('is_active')->boolean(),
|
|
TextColumn::make('name')->searchable(),
|
|
TextColumn::make('organization.name')->sortable(),
|
|
TextColumn::make('guid')->searchable(),
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListDepartments::route('/'),
|
|
'create' => Pages\CreateDepartment::route('/create'),
|
|
'edit' => Pages\EditDepartment::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|