wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\User;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Tables\Columns\ViewColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class PlayerPropsTable extends TableWidget
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
protected int|string|array $columnSpan = 2;
|
||||
|
||||
public int $team_id;
|
||||
|
||||
public array $players;
|
||||
|
||||
#[On('update-players')]
|
||||
public function updatePlayers(array $players)
|
||||
{
|
||||
$this->players = $players;
|
||||
}
|
||||
|
||||
public function getHeadingTable(): HtmlString
|
||||
{
|
||||
|
||||
return new HtmlString('
|
||||
<div class="w-full grid grid-cols-15 text-[10px] items-center gap-1" style="position: relative; left: -10px; bottom: -13px;">
|
||||
<div>Gls</div>
|
||||
<div>Fls</div>
|
||||
<div>Ofs</div>
|
||||
<div>Crd</div>
|
||||
<div>Snt</div>
|
||||
<div>Tsh</div>
|
||||
<div>Foot</div>
|
||||
<div>Evt</div>
|
||||
<div>Min</div>
|
||||
|
||||
</div>');
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->heading(false)
|
||||
->query(User::query()->whereRaw('1 = 0')) // Verhindert DB-Abfragen
|
||||
->striped()
|
||||
->defaultSort('name')
|
||||
->emptyStateHeading('No team selected')
|
||||
->columns([
|
||||
ViewColumn::make('drag_card')
|
||||
->label(fn() => $this->getHeadingTable())
|
||||
->view('filament.tables.columns.drag-card'),
|
||||
])->extraAttributes([
|
||||
'id' => 'playerdragtable',
|
||||
])
|
||||
->filters([
|
||||
Filter::make('positions')
|
||||
->columnSpan(2)
|
||||
->schema([
|
||||
Select::make('area')
|
||||
->hiddenLabel()
|
||||
->placeholder('Filter Positions')
|
||||
->native(false)
|
||||
->allowHtml()
|
||||
->options([
|
||||
'attack' => '<span class="text-amber-500">Attack</span>',
|
||||
'midfield' => '<span class="text-blue-500">Midfield</span>',
|
||||
'defence' => '<span class="text-green-500">Defence</span>',
|
||||
'goalkeeper' => '<span class="text-gray-500">Goalkeeper</span>',
|
||||
]),
|
||||
])
|
||||
->query(function ($query) {
|
||||
return $query;
|
||||
})->indicateUsing(function (array $data): array {
|
||||
// empty array disables indicator-badge
|
||||
return [];
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->records(function () {
|
||||
$collection = collect($this->players)->sortBy('order')->sortBy('active', SORT_NUMERIC, 1);
|
||||
$selectedPosition = $this->tableFilters['positions']['area'] ?? null;
|
||||
if (! empty($selectedPosition)) {
|
||||
$collection = $collection->where('area', $selectedPosition);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user