78 lines
3.0 KiB
PHP
78 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Projektes\Tables;
|
|
|
|
use App\Actions\Klone\KloneDokument;
|
|
use App\Enums\ProjektStatus;
|
|
use App\Models\Auftraggeber;
|
|
use App\Models\Gutachter;
|
|
use App\Models\Projekte;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Enums\FiltersLayout;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Support\HtmlString;
|
|
|
|
class ProjektesTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('id'),
|
|
TextColumn::make('interner_name')
|
|
->tooltip(fn ($record): HtmlString => new HtmlString($record->beschreibung))
|
|
->label('Interner Name')
|
|
->color('primary')
|
|
->wrap()
|
|
->searchable(),
|
|
TextColumn::make('offizieller_name')
|
|
->wrap()
|
|
->searchable()
|
|
->label('Offizieller Name'),
|
|
TextColumn::make('gutachter.company'),
|
|
TextColumn::make('auftraggeber.company'),
|
|
TextColumn::make('ort'),
|
|
TextColumn::make('erstellung')->sortable(),
|
|
])
|
|
->striped()
|
|
->defaultSort('erstellung', direction: 'desc')
|
|
->persistSortInSession()
|
|
->filters([
|
|
SelectFilter::make('status')
|
|
->options(ProjektStatus::class),
|
|
SelectFilter::make('gutachter_id')
|
|
->label('Gutachter')
|
|
->preload()
|
|
->options(function () {
|
|
$res = Projekte::where('konto_id', auth()->user()->konto_id)
|
|
->groupBy('gutachter_id')
|
|
->pluck('gutachter_id')->toArray();
|
|
|
|
return Gutachter::query()->whereIn('id', $res)->orderBy('company')->pluck('company', 'id');
|
|
}),
|
|
SelectFilter::make('auftraggeber_id')
|
|
->label('Auftraggeber')
|
|
->preload()
|
|
->options(function () {
|
|
$res = Projekte::where('konto_id', auth()->user()->konto_id)
|
|
->groupBy('auftraggeber_id')
|
|
->pluck('auftraggeber_id')->toArray();
|
|
|
|
return Auftraggeber::query()->whereIn('id', $res)->orderBy('company')->pluck('company', 'id');
|
|
}),
|
|
], FiltersLayout::AboveContent)
|
|
->deferFilters(false)
|
|
->recordActions([
|
|
EditAction::make()->iconButton(),
|
|
Action::make('dokument_klonen')
|
|
->action(fn (Projekte $record) => KloneDokument::clone($record))
|
|
->iconButton()
|
|
->icon('phosphor-copy')
|
|
->requiresConfirmation(),
|
|
]);
|
|
}
|
|
}
|