ComparingBookmakerMenu wip
This commit is contained in:
1 parent
d07277ae06
commit
de95867692
7 files changed
+146
-74
No files matched your search
@@ -2,17 +2,26 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Models\ComparingBookmaker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
class ComparingBookmakerMenu extends Component implements HasActions, HasSchemas, HasTable
|
||||
@@ -23,43 +32,96 @@ class ComparingBookmakerMenu extends Component implements HasActions, HasSchemas
|
||||
|
||||
public $active_methode = 1;
|
||||
|
||||
protected $listeners = [
|
||||
'refresh' => '$refresh',
|
||||
];
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->description('Bookmaker higher up will be used first.')
|
||||
->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(function ($livewire) {
|
||||
$this->active_methode = 1;
|
||||
$livewire->getTableRecords()->fresh();
|
||||
}),
|
||||
->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'),
|
||||
->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'),
|
||||
->icon('phosphor-cell-signal-medium')
|
||||
->after(fn () => $this->dispatch('refresh')),
|
||||
|
||||
])
|
||||
->reorderable('sorting')
|
||||
->paginated(false)
|
||||
->striped()
|
||||
->query(ComparingBookmaker::query()
|
||||
->where('is_hidden', 0)
|
||||
->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))
|
||||
->where('method_id', $this->active_methode)
|
||||
->orderBy('sorting'))
|
||||
->columns([
|
||||
TextColumn::make('id'),
|
||||
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'),
|
||||
])
|
||||
->paginated(false)
|
||||
->filters([
|
||||
// ...
|
||||
])
|
||||
->recordActions([
|
||||
// ...
|
||||
])
|
||||
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]
|
||||
);
|
||||
}
|
||||
}),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user