97 lines
3.5 KiB
PHP
97 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Filament\Tables\Columns\MapperLeftColumn;
|
|
use App\Models\Event;
|
|
use App\Models\Mapper;
|
|
use Carbon\Carbon;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\Concerns\InteractsWithActions;
|
|
use Filament\Actions\Contracts\HasActions;
|
|
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
|
use Filament\Schemas\Contracts\HasSchemas;
|
|
use Filament\Support\Enums\Alignment;
|
|
use Filament\Tables\Concerns\InteractsWithTable;
|
|
use Filament\Tables\Contracts\HasTable;
|
|
use Filament\Tables\Enums\FiltersLayout;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Livewire\Component;
|
|
|
|
class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
|
{
|
|
use InteractsWithActions;
|
|
use InteractsWithSchemas;
|
|
use InteractsWithTable;
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->query(Event::query()->where('betradar_id', 0))
|
|
->columns([
|
|
MapperLeftColumn::make('left')->label(''),
|
|
])->searchable(['home.name', 'away.name'])
|
|
->defaultPaginationPageOption(5)
|
|
->filters([
|
|
SelectFilter::make('country_id')
|
|
->relationship('country', 'name')
|
|
->options(
|
|
fn (Builder $query) => $query->whereNotNull('events.country_id')->where('events.betradar_id', 0)->where('events.starttime', '>', Carbon::now())
|
|
)
|
|
->searchable()
|
|
->preload()
|
|
->multiple()
|
|
->placeholder('Country')
|
|
->label('Countries'),
|
|
SelectFilter::make('competition_group_id')
|
|
->options(function () {
|
|
$res = Event::with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
|
|
$arr = [];
|
|
foreach ($res as $val) {
|
|
$arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group->name;
|
|
}
|
|
asort($arr);
|
|
|
|
return $arr;
|
|
})
|
|
->columnSpan(2)
|
|
->searchable()
|
|
->preload()
|
|
->multiple()
|
|
->placeholder('League')
|
|
->label('Leagues'),
|
|
], layout: FiltersLayout::AboveContent)
|
|
->hiddenFilterIndicators()
|
|
->filtersFormColumns(3)
|
|
->deferFilters(false)
|
|
->toolbarActions([
|
|
// ...
|
|
]);
|
|
}
|
|
|
|
public function leftAction(): Action
|
|
{
|
|
return Action::make('left')
|
|
->modalHeading('Event Mapper')
|
|
->modalContent(function (array $arguments) {
|
|
$event = Event::where('id', $arguments['match_id'])->first();
|
|
|
|
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
|
|
|
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper, 'mappermode' => 'linear']);
|
|
})
|
|
->modalAlignment(Alignment::Center)
|
|
->modalFooterActionsAlignment(Alignment::Center)
|
|
->modalWidth('2xl')
|
|
->modalSubmitActionLabel('Confirm')
|
|
->modalSubmitAction();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.mapper-left');
|
|
}
|
|
}
|