EventsTable fix multiple filter select
This commit is contained in:
1 parent
3e3330bf80
commit
ba2bf5b19a
2 files changed
+50
-46
No files matched your search
@@ -22,9 +22,7 @@ use App\Models\OddsTable;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -43,7 +41,6 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class EventsTable
|
||||
{
|
||||
@@ -216,7 +213,11 @@ class EventsTable
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function () {
|
||||
$res = Event::where('has_markets', 1)->where('sport_id', auth()->user()->sport_id)->whereDate('starttime', '>=', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
|
||||
$res = Event::where('has_markets', 1)
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('starttime', '>=', Carbon::now())
|
||||
->groupBy('country_id')
|
||||
->pluck('country_id')->toArray();
|
||||
|
||||
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
@@ -235,10 +236,22 @@ class EventsTable
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
$res = Event::where('has_markets', 1)->where('sport_id', auth()->user()->sport_id)->with('country')->with('competition_group')->where('country_id', $get('country_id'))->whereDate('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
|
||||
$res = Event::where('has_markets', 1)
|
||||
->with('country')
|
||||
->with('competition_group')
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->whereIn('country_id', $get('country_id'))
|
||||
->groupBy('competition_group_id')->get();
|
||||
} else {
|
||||
$res = Event::where('has_markets', 1)->where('sport_id', auth()->user()->sport_id)->with('country')->with('competition_group')->whereDate('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
|
||||
$res = Event::where('has_markets', 1)
|
||||
->with('country')
|
||||
->with('competition_group')
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->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;
|
||||
@@ -260,9 +273,22 @@ class EventsTable
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
$res = Event::where('has_markets', 1)->with('country')->where('sport_id', auth()->user()->sport_id)->with('group')->where('country_id', $get('country_id'))->whereDate('starttime', '>', Carbon::now())->groupBy('group_id')->get();
|
||||
$res = Event::where('has_markets', 1)
|
||||
->with('country')
|
||||
->with('group')
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('country_id', $get('country_id'))
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->groupBy('group_id')
|
||||
->get();
|
||||
} else {
|
||||
$res = Event::where('has_markets', 1)->with('country')->where('sport_id', auth()->user()->sport_id)->with('group')->whereDate('starttime', '>', Carbon::now())->groupBy('group_id')->get();
|
||||
$res = Event::where('has_markets', 1)
|
||||
->with('country')
|
||||
->with('group')
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->groupBy('group_id')
|
||||
->get();
|
||||
}
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
@@ -280,7 +306,9 @@ class EventsTable
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->preload()
|
||||
->options(fn () => ClientGroupList::where('sport_id', auth()->user()->sport_id)->where('client_id', auth()->user()->client_id)->pluck('name', 'id'))
|
||||
->options(fn () => ClientGroupList::where('sport_id', auth()->user()->sport_id)
|
||||
->where('client_id', auth()->user()->client_id)
|
||||
->pluck('name', 'id'))
|
||||
->live(),
|
||||
|
||||
DateRangePicker::make('starttime_period')
|
||||
@@ -312,7 +340,9 @@ class EventsTable
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['country_id'],
|
||||
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
|
||||
function (Builder $query, $country_id) {
|
||||
$query->whereIn('country_id', $country_id);
|
||||
}
|
||||
)->when(
|
||||
$data['group_id'],
|
||||
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
|
||||
@@ -496,28 +526,6 @@ class EventsTable
|
||||
$indicators[] = Indicator::make('To Qualify')->color('info')->removable(false);
|
||||
}
|
||||
|
||||
// if (auth()->user()->all_only_none == 1) {
|
||||
// $indicators[] = Indicator::make('With '.auth()->user()->bookmaker->name)->color('info')->removable(false);
|
||||
// }
|
||||
// if (auth()->user()->all_only_none == 2) {
|
||||
// $indicators[] = Indicator::make('Without '.auth()->user()->bookmaker->name)->color('info')->removable(false);
|
||||
// }
|
||||
|
||||
// if (auth()->user()->partner_show == 1) {
|
||||
// $indicators[] = Indicator::make('With '.auth()->user()->partnerbookmaker->name)->color('info')->removable(false);
|
||||
// }
|
||||
// if (auth()->user()->partner_compare == 1) {
|
||||
// $indicators[] = Indicator::make('Difference odds '.auth()->user()->bookmaker->name.' vs '.auth()->user()->partnerbookmaker->name)->color('info')->removable(false);
|
||||
// }
|
||||
|
||||
// if (auth()->user()->bookmaker_partner_differences == 1) {
|
||||
// // wire:click="toggleComparePartner"
|
||||
// $indicators[] = Indicator::make('missing')
|
||||
// ->label(new HtmlString('<string class="cursor-pointer" wire:click="toggleMissing">'.auth()->user()->bookmaker->name.' vs '.auth()->user()->partnerbookmaker->name.'</string>'))
|
||||
// ->color('info')
|
||||
// ->removable(false);
|
||||
// }
|
||||
|
||||
if ($data['filter_notes'] ?? null) {
|
||||
$indicators[] = Indicator::make('Notes')->removeField('filter_notes')->color('info');
|
||||
}
|
||||
@@ -699,10 +707,6 @@ class EventsTable
|
||||
|
||||
])->iconButton()
|
||||
->icon('phosphor-dots-three-vertical'),
|
||||
// ])->toolbarActions([
|
||||
// BulkActionGroup::make([
|
||||
// DeleteBulkAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
|
||||
// ]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user