mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-07 21:33:18 +01:00
104 lines
3.2 KiB
PHP
104 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\TaskResource\Pages\CreateTask;
|
|
use App\Filament\Resources\TaskResource\Pages\EditTask;
|
|
use App\Filament\Resources\TaskResource\Pages\ListTasks;
|
|
use App\Models\Task;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class TaskResource extends Resource
|
|
{
|
|
protected static ?string $model = Task::class;
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-list-bullet';
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Timetracking';
|
|
|
|
protected static ?int $navigationSort = 3;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('name')
|
|
->label('Name')
|
|
->required()
|
|
->maxLength(255),
|
|
Select::make('project_id')
|
|
->relationship(name: 'project', titleAttribute: 'name')
|
|
->searchable(['name'])
|
|
->required(),
|
|
Select::make('organization_id')
|
|
->relationship(name: 'organization', titleAttribute: 'name')
|
|
->searchable(['name'])
|
|
->required(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('project.name')
|
|
->sortable(),
|
|
TextColumn::make('organization.name')
|
|
->sortable(),
|
|
TextColumn::make('created_at')
|
|
->sortable(),
|
|
TextColumn::make('updated_at')
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('organization')
|
|
->label('Organization')
|
|
->relationship('organization', 'name')
|
|
->searchable(),
|
|
SelectFilter::make('organization_id')
|
|
->label('Organization ID')
|
|
->relationship('organization', 'id')
|
|
->searchable(),
|
|
])
|
|
->defaultSort('created_at', 'desc')
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListTasks::route('/'),
|
|
'create' => CreateTask::route('/create'),
|
|
'edit' => EditTask::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|