ComparingBookmakerMenu ok
This commit is contained in:
1 parent
be80128226
commit
f59ac10c2a
17 files changed
+272
-317
No files matched your search
@@ -3,14 +3,13 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Livewire\ComparingBookmaker\LoadBookmaker;
|
||||
use App\Models\ComparingBookmaker;
|
||||
use App\Models\User;
|
||||
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\Radio;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
@@ -20,12 +19,9 @@ use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -35,83 +31,57 @@ class ComparingBookmakerMenu extends Component implements HasActions, HasSchemas
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $user;
|
||||
|
||||
protected $listeners = [
|
||||
'refresh' => '$refresh',
|
||||
];
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
$this->user = User::getUser();
|
||||
|
||||
return $table
|
||||
->description('')
|
||||
->description('Bookmaker order is priority. Maximum time than can pass since last check or update. If older bookmaker will be ignored')
|
||||
->description('Bookmakers will be compared from top to bottom. First one matches criteria is used for comparition.')
|
||||
->reorderable('sorting')
|
||||
->reorderRecordsTriggerAction(function (Action $action) {
|
||||
return $action->button();
|
||||
})
|
||||
->paginated(false)
|
||||
->striped()
|
||||
->query(LoadBookmaker::load())
|
||||
->query(ComparingBookmaker::query()
|
||||
->with('bookmaker')
|
||||
->where('sport_id', $this->user->sport_id)
|
||||
->where('client_bookmaker_id', $this->user->bookmaker_id)
|
||||
->orderBy('sorting')
|
||||
)
|
||||
->columns([
|
||||
TextColumn::make('Position')
|
||||
->alignCenter()
|
||||
->badge()
|
||||
->rowIndex(),
|
||||
TextColumn::make('bookmaker_id')->label('Id'),
|
||||
BookmakerIcon::make('bookmaker.icon')->label('Icon'),
|
||||
BookmakerIcon::make('bookmaker.icon')->label('Icon')->size('lg'),
|
||||
TextInputColumn::make('time_lastcheck')
|
||||
->tooltip('If lastcheck is older bookmaker will be ignored')
|
||||
->label('Time Passed')
|
||||
->prefix('Seconds:')
|
||||
->rules(['required', 'max:200', 'min:100']),
|
||||
TextInputColumn::make('margin_threshold')
|
||||
->tooltip('If margin is higher bookmaker will be ignored')
|
||||
->label('Maximum Margin')
|
||||
->prefix('Threshold:')
|
||||
->rules(['required', 'max:200', 'min:100']),
|
||||
ToggleColumn::make('is_active'),
|
||||
// ToggleColumn::make('is_active'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('method_id')
|
||||
->schema([
|
||||
Radio::make('method_id')
|
||||
->inline()
|
||||
->default(1)
|
||||
->label('League / Tournament Level')
|
||||
->options([
|
||||
1 => 'TOP',
|
||||
2 => 'MIDDLE',
|
||||
3 => 'LOW',
|
||||
]),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['method_id'],
|
||||
fn (Builder $query, $method_id): Builder => $query->where('method_id', $method_id),
|
||||
);
|
||||
})->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
|
||||
if ($data['method_id'] ?? null) {
|
||||
switch ($data['method_id']) {
|
||||
case 1:
|
||||
$indicators[] = Indicator::make('Method: TOP');
|
||||
break;
|
||||
case 2:
|
||||
$indicators[] = Indicator::make('Method: MIDDLE');
|
||||
break;
|
||||
case 3:
|
||||
$indicators[] = Indicator::make('Method: LOW');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})->columnSpan(6),
|
||||
TernaryFilter::make('is_active')
|
||||
->columnSpan(2)
|
||||
->default(1)
|
||||
->label('Show active'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->filtersFormColumns(8)
|
||||
->searchable(['bookmaker.name'])
|
||||
// ->filters([
|
||||
// TernaryFilter::make('is_active')
|
||||
// ->columnSpan(2)
|
||||
// ->default(1)
|
||||
// ->label('Show active'),
|
||||
// ], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
|
||||
Reference in new issue
Block a user