wip
This commit is contained in:
1 parent
ac41bc317a
commit
32cc345125
6 files changed
+457
-414
No files matched your search
+100
-105
@@ -16,7 +16,6 @@ use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\FusedGroup;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
@@ -32,11 +31,9 @@ use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Attributes\Lazy;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Lazy]
|
||||
class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
@@ -101,122 +98,120 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
->filters([
|
||||
Filter::make('events')
|
||||
->schema([
|
||||
FusedGroup::make([
|
||||
Select::make('country_id')
|
||||
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]) && auth()->user()->sport_id != 5)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('country_id')->orderBy('country');
|
||||
Select::make('country_id')
|
||||
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]) && auth()->user()->sport_id != 5)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('country_id')->orderBy('country');
|
||||
|
||||
$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']);
|
||||
$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)->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);
|
||||
}
|
||||
$query->where('starttime', '<=', $end);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->pluck('country', 'country_id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_cc')
|
||||
->visible(fn () => auth()->user()->provider_id == 2)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('group_cc');
|
||||
return $query->pluck('country', 'country_id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_cc')
|
||||
->visible(fn () => auth()->user()->provider_id == 2)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('group_cc');
|
||||
|
||||
$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']);
|
||||
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)->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);
|
||||
}
|
||||
$query->where('starttime', '<=', $end);
|
||||
}
|
||||
if ($get('country_id') ?? null) {
|
||||
$res = $query->where('country_id', $get('country_id'))->pluck('group_cc')->toArray();
|
||||
} else {
|
||||
$res = $query->pluck('group_cc')->toArray();
|
||||
}
|
||||
if ($get('country_id') ?? null) {
|
||||
$res = $query->where('country_id', $get('country_id'))->pluck('group_cc')->toArray();
|
||||
} else {
|
||||
$res = $query->pluck('group_cc')->toArray();
|
||||
}
|
||||
|
||||
return Country::query()->whereIn('iso2', $res)->orderBy('name')->pluck('name', 'iso2');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_id')
|
||||
->placeholder('League')
|
||||
->label('Leagues')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('country_id', $get('country_id'))->groupBy('group_id');
|
||||
} elseif ($get('group_cc')) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('group_cc', $get('group_cc'))->groupBy('group_id');
|
||||
} else {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('group_id');
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
return Country::query()->whereIn('iso2', $res)->orderBy('name')->pluck('name', 'iso2');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_id')
|
||||
->placeholder('League')
|
||||
->label('Leagues')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('country_id', $get('country_id'))->groupBy('group_id');
|
||||
} elseif ($get('group_cc')) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('group_cc', $get('group_cc'))->groupBy('group_id');
|
||||
} else {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('group_id');
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->pluck('group', 'group_id')->toArray();
|
||||
})
|
||||
->live(),
|
||||
])->columnSpan(2),
|
||||
return $query->pluck('group', 'group_id')->toArray();
|
||||
})
|
||||
->live(),
|
||||
DateRangePicker::make('starttime_period')
|
||||
->columnSpan(2)
|
||||
->displayFormat('d M Y')
|
||||
|
||||
Reference in new issue
Block a user