mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-08 05:43:18 +01:00
102 lines
3.1 KiB
PHP
102 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\ClientResource\Pages\CreateClient;
|
|
use App\Filament\Resources\ClientResource\Pages\EditClient;
|
|
use App\Filament\Resources\ClientResource\Pages\ListClients;
|
|
use App\Models\Client;
|
|
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 ClientResource extends Resource
|
|
{
|
|
protected static ?string $model = Client::class;
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-briefcase';
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Timetracking';
|
|
|
|
protected static ?int $navigationSort = 4;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('name')
|
|
->label('Name')
|
|
->required(),
|
|
Select::make('organization_id')
|
|
->relationship(name: 'organization', titleAttribute: 'name')
|
|
->label('Organization')
|
|
->searchable(['name'])
|
|
->required(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->label('Name')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('organization.name')
|
|
->sortable()
|
|
->label('Organization'),
|
|
TextColumn::make('created_at')
|
|
->label('Created at')
|
|
->sortable(),
|
|
TextColumn::make('updated_at')
|
|
->label('Updated at')
|
|
->sortable(),
|
|
])
|
|
->defaultSort('created_at', 'desc')
|
|
->filters([
|
|
SelectFilter::make('organization')
|
|
->label('Organization')
|
|
->relationship('organization', 'name')
|
|
->searchable(),
|
|
SelectFilter::make('organization_id')
|
|
->label('Organization ID')
|
|
->relationship('organization', 'id')
|
|
->searchable(),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListClients::route('/'),
|
|
'create' => CreateClient::route('/create'),
|
|
'edit' => EditClient::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|