ComparingBookmakerMenu wip

This commit is contained in:
salam committed 2026-01-20 14:50:04 +01:00
1 parent d07277ae06
commit de95867692
7 files changed
+146 -74

No files matched your search

@@ -25,55 +25,55 @@ class GenerateDefaultSetting
Notice::note('GENERATE DEFAULT SETTING', 'b');
}
// if ($debug) {
// Notice::note('1) multiline bookmaker slots for client', 'p');
// }
if ($debug) {
Notice::note('1) multiline bookmaker slots for client', 'p');
}
// $sports = Sport::where('is_active', 1)->pluck('id');
$sports = Sport::where('is_active', 1)->pluck('id');
// $bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126];
$bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126];
// $clients = Client::get()->pluck('id');
$clients = Client::get()->pluck('id');
// foreach ($clients as $client_id) {
foreach ($clients as $client_id) {
// foreach ($sports as $sport_id) {
foreach ($sports as $sport_id) {
// $multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id');
$multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id');
// foreach ($multilines as $multiline_id) {
foreach ($multilines as $multiline_id) {
// foreach ($bookmaker_slots as $slot => $bookmaker_id) {
foreach ($bookmaker_slots as $slot => $bookmaker_id) {
// MultilineClient::firstOrCreate(
// ['client_id' => $client_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'position' => $slot],
// ['bookmaker_id' => $bookmaker_id, 'sort' => $slot, 'disabled' => 0]
// );
// }
// }
// }
// }
MultilineClient::firstOrCreate(
['client_id' => $client_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'position' => $slot],
['bookmaker_id' => $bookmaker_id, 'sort' => $slot, 'disabled' => 0]
);
}
}
}
}
// if ($debug) {
// Notice::note('2) generator bettypes im comparatore for users', 'p');
// }
if ($debug) {
Notice::note('2) generator bettypes im comparatore for users', 'p');
}
// $users = User::get();
$users = User::get();
// foreach ($users as $user) {
foreach ($users as $user) {
// $multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', 'id');
$multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', 'id');
// foreach ($multilines as $multiline_setting_id => $sport_id) {
foreach ($multilines as $multiline_setting_id => $sport_id) {
// $is_active = in_array($multiline_setting_id, [1, 2, 9, 10, 16, 17, 22, 23]) ? 1 : 0;
$is_active = in_array($multiline_setting_id, [1, 2, 9, 10, 16, 17, 22, 23]) ? 1 : 0;
// BettypeUser::firstOrCreate(
// ['sport_id' => $sport_id, 'user_id' => $user->id, 'multiline_setting_id' => $multiline_setting_id],
// ['is_active' => $is_active]
// );
// }
// }
BettypeUser::firstOrCreate(
['sport_id' => $sport_id, 'user_id' => $user->id, 'multiline_setting_id' => $multiline_setting_id],
['is_active' => $is_active]
);
}
}
if ($debug) {
Notice::note('3) comparing bookmaker', 'p');
@@ -94,8 +94,6 @@ class EventsTable
->columns([
IconColumn::make('sport.icon')
->label('')
->grow(false)
->width(30)
->icon(fn ($record) => $record->sport->icon)
->tooltip(fn ($record) => $record->id)
->visibleFrom('lg'),
@@ -228,7 +226,9 @@ class EventsTable
->reactive()
->afterStateUpdated(function (callable $set, $state, $livewire) {
User::where('id', auth()->user()->id)->update(['sport_id' => $state]);
auth()->user()->sport_id = (int) $state;
User::where('id', auth()->user()->id)->update(['sport_id' => (int) $state]);
$livewire->dispatch('refreshBettypeMenu');
+79 -17
View File
@@ -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]
);
}
}),
]),
]);
}
+10
View File
@@ -17,4 +17,14 @@ class ComparingBookmaker extends Model
'is_hidden',
'sorting',
];
public function bookmaker()
{
return $this->belongsTo(Bookmaker::class);
}
public function sport()
{
return $this->belongsTo(Sport::class);
}
}