'$refresh', ]; public function table(Table $table): Table { return $table ->description('') ->description('Bookmaker order is priority. Maximum time than can pass since last check or update. If older bookmaker will be ignored') ->headerActions([ Action::make('top') ->color(fn () => $this->active_methode == 1 ? 'primary' : 'gray') ->icon('phosphor-cell-signal-full') ->action(fn () => $this->active_methode = 1) ->after(fn () => $this->dispatch('refresh')), Action::make('middle')->action(fn () => $this->active_methode = 2) ->color(fn () => $this->active_methode == 2 ? 'primary' : 'gray') ->icon('phosphor-cell-signal-high') ->after(fn () => $this->dispatch('refresh')), Action::make('low')->action(fn () => $this->active_methode = 3) ->color(fn () => $this->active_methode == 3 ? 'primary' : 'gray') ->icon('phosphor-cell-signal-medium') ->after(fn () => $this->dispatch('refresh')), ]) ->reorderable('sorting') ->paginated(false) ->striped() ->query(ComparingBookmaker::query() ->with('bookmaker') // ->where('is_hidden', 0) ->where('sport_id', auth()->user()->sport_id) ->where('client_bookmaker_id', auth()->user()->bookmaker_id) ->where('method_id', $this->active_methode) ->orderBy('sorting')) ->columns([ TextColumn::make('Position') ->alignCenter() ->badge() ->rowIndex(), // IconColumn::make('sport.icon') // ->label('') // ->icon(fn ($record) => $record->sport->icon) // ->visibleFrom('lg'), BookmakerIcon::make('bookmaker.icon')->label('Icon'), TextColumn::make('time_lastcheck')->label('Time Passed'), TextColumn::make('margin_threshold'), ToggleColumn::make('is_active'), ]) ->filters([ TernaryFilter::make('is_active')->default(1)->label('Show active'), ], layout: FiltersLayout::AboveContent) ->deferFilters(false) ->toolbarActions([ BulkActionGroup::make([ BulkAction::make('time_lastcheck') ->label('Max time since last check in seconds') ->icon('phosphor-timer') ->action(function (Collection $records, array $data): void { foreach ($records as $record) { ComparingBookmaker::where('id', '=', $record->id) ->update( ['time_lastcheck' => $data['time_lastcheck']] ); } }) ->form([ TextInput::make('time_lastcheck')->hiddenLabel()->prefix('Seconds'), ]), BulkAction::make('Switch On') ->icon('phosphor-play') ->action(function (Collection $records): void { foreach ($records as $record) { ComparingBookmaker::where('id', '=', $record->id) ->update( ['is_active' => 1] ); } }), BulkAction::make('Switch Off') ->icon('phosphor-stop') ->action(function (Collection $records): void { foreach ($records as $record) { ComparingBookmaker::where('id', '=', $record->id) ->update( ['is_active' => 0] ); } }), ]), ]); } public function render(): View { return view('livewire.comparing-bookmaker-menu'); } }