This commit is contained in:
salam committed 2026-03-25 12:20:15 +01:00
1 parent ac41bc317a
commit 32cc345125
6 files changed
+457 -414

No files matched your search

+81 -86
View File
@@ -16,7 +16,6 @@ use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\FusedGroup;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
@@ -31,11 +30,9 @@ use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\Indicator;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Attributes\Lazy;
use Livewire\Attributes\On;
use Livewire\Component;
#[Lazy]
class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
{
use InteractsWithActions;
@@ -100,100 +97,98 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
Filter::make('events')
->columns(4)
->schema([
FusedGroup::make([
Select::make('country_id')
->placeholder('Country')
->visible(fn () => auth()->user()->sport_id != 5)
->hiddenLabel()
->searchable()
->preload()
->options(function (Get $get) {
$query = Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0)->groupBy('country_id');
Select::make('country_id')
->placeholder('Country')
->visible(fn () => auth()->user()->sport_id != 5)
->hiddenLabel()
->searchable()
->preload()
->options(function (Get $get) {
$query = Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0)->groupBy('country_id');
$timeframe = $get('starttime_period') ?? [];
$timeframe = $get('starttime_period') ?? [];
if ($timeframe['start'] || $timeframe['end']) {
if (isset($timeframe['start']) && isset($timeframe['end'])) {
$from = Carbon::createFromDate($timeframe['start']);
$end = Carbon::createFromDate($timeframe['end']);
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
} elseif (isset($timeframe['start'])) {
$from = Carbon::createFromDate($timeframe['start']);
$query->where('starttime', '>=', $from);
} elseif (isset($timeframe['end'])) {
$end = Carbon::createFromDate($timeframe['end']);
$query->where('starttime', '<=', $end);
}
}
$res = $query->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
})
->afterStateUpdated(function (callable $set) {
$set('competition_group_id', null);
})
->live(),
Select::make('competition_group_id')
->placeholder('League')
->hiddenLabel()
->label('')
->searchable()
->options(function (Get $get) {
$query = CompetitionGroup::where('sport_id', auth()->user()->sport_id)
->whereHas('event', function ($query) {
$query->where('betradar_id', 0);
});
if ($get('country_id') ?? null) {
$res = $query->where('country_id', $get('country_id'))->get();
} else {
$timeframe = $get('starttime_period') ?? null;
if ($timeframe['start'] || $timeframe['end']) {
if (isset($timeframe['start']) && isset($timeframe['end'])) {
$from = Carbon::createFromDate($timeframe['start']);
$end = Carbon::createFromDate($timeframe['end']);
$query->whereHas('event', function ($query) {
if (isset($timeframe['start']) && isset($timeframe['end'])) {
$from = Carbon::createFromDate($timeframe['start']);
$end = Carbon::createFromDate($timeframe['end']);
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
} elseif (isset($timeframe['start'])) {
$from = Carbon::createFromDate($timeframe['start']);
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
} elseif (isset($timeframe['start'])) {
$from = Carbon::createFromDate($timeframe['start']);
$query->where('starttime', '>=', $from);
} elseif (isset($timeframe['end'])) {
$end = Carbon::createFromDate($timeframe['end']);
$query->where('starttime', '>=', $from);
} elseif (isset($timeframe['end'])) {
$end = Carbon::createFromDate($timeframe['end']);
$query->where('starttime', '<=', $end);
}
}
$res = $query->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
})
->afterStateUpdated(function (callable $set) {
$set('competition_group_id', null);
})
->live(),
Select::make('competition_group_id')
->placeholder('League')
->hiddenLabel()
->label('')
->searchable()
->options(function (Get $get) {
$query = CompetitionGroup::where('sport_id', auth()->user()->sport_id)
->whereHas('event', function ($query) {
$query->where('betradar_id', 0);
$query->where('starttime', '<=', $end);
}
});
if ($get('country_id') ?? null) {
$res = $query->where('country_id', $get('country_id'))->get();
}
if (auth()->user()->sport_id != 5) {
$res = $query->groupBy('country_id')->get();
} else {
$timeframe = $get('starttime_period') ?? null;
if ($timeframe['start'] || $timeframe['end']) {
$query->whereHas('event', function ($query) {
if (isset($timeframe['start']) && isset($timeframe['end'])) {
$from = Carbon::createFromDate($timeframe['start']);
$end = Carbon::createFromDate($timeframe['end']);
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
} elseif (isset($timeframe['start'])) {
$from = Carbon::createFromDate($timeframe['start']);
$query->where('starttime', '>=', $from);
} elseif (isset($timeframe['end'])) {
$end = Carbon::createFromDate($timeframe['end']);
$query->where('starttime', '<=', $end);
}
});
}
if (auth()->user()->sport_id != 5) {
$res = $query->groupBy('country_id')->get();
} else {
$res = $query->get();
}
$res = $query->get();
}
$arr = [];
$map = Country::all()->pluck('name', 'id')->toArray();
foreach ($res as $value) {
if (isset($map[$value->country_id])) {
$arr[$value->id] = $map[$value->country_id].' '.$value->name;
} else {
$arr[$value->id] = $value->name;
}
}
$arr = [];
$map = Country::all()->pluck('name', 'id')->toArray();
foreach ($res as $value) {
if (isset($map[$value->country_id])) {
$arr[$value->id] = $map[$value->country_id].' '.$value->name;
} else {
$arr[$value->id] = $value->name;
}
asort($arr);
}
asort($arr);
return $arr;
})
->live(),
])->columnSpan(2),
return $arr;
})
->live(),
DateRangePicker::make('starttime_period')
->displayFormat('d M Y')
->columnSpan(2)