diff --git a/app/Actions/AlarmGenerator.php b/app/Actions/AlarmGenerator.php new file mode 100644 index 00000000..2e553801 --- /dev/null +++ b/app/Actions/AlarmGenerator.php @@ -0,0 +1,12 @@ +id; - // odds_2ways - // odds_3ways - // odds_dc - // odds_dnb - // odds_ggng - // odds_handicaps - // odds_qualify - // odds_totals + Multiline::where('client_id', $client_id)->update(['disabled' => 1]); - $default = []; - $default[1] = [ - 'bettypes' => [1, 16, 3, 4, 5], - ]; + foreach ($record->sport as $sportid) { - $multilines = Multiline::where('client_id', auth()->user()->client_id)->get(); - dd($multilines); + $multilines = MultilineSetting::where('sport_id', $sportid)->get(); - foreach ($slots as $id => $slot) { - $open = true; - foreach ($data as $item) { - if ($slot->bookmaker_id == $item->bookmaker_id) { - $multilines[$id] = $item; - $open = false; + foreach ($multilines as $multiline) { + + for ($i = 1; $i <= $multiline->rows; $i++) { + + Multiline::updateOrCreate( + ['client_id' => $client_id, 'sport_id' => $sportid], + ['name' => $multiline->name, 'table' => $multiline->table, 'sort' => $i, 'disabled' => 0] + ); } } - if ($open) { - $multilines[$id] = $slot; - } + } - return $multilines; + Notification::make() + ->title('Multiline generated successfully') + ->success() + ->send(); + } } diff --git a/app/Actions/SupervisorDb.php b/app/Actions/SupervisorDb.php index dc60a9e5..82ee3e33 100644 --- a/app/Actions/SupervisorDb.php +++ b/app/Actions/SupervisorDb.php @@ -44,7 +44,7 @@ class SupervisorDb $tmp['command'] = $process->process.$sport->code; $tmp['sport_id'] = $sport->id; $tmp['description'] = $process->description.' '.$sport->sport; - $flight = Supervisor::updateOrCreate( + Supervisor::updateOrCreate( ['code' => $process->command.$sport->code, 'sport_id' => $sport->id], ['command' => $process->process.$sport->code, 'description' => $process->description] ); diff --git a/app/Filament/Resources/Clients/Tables/ClientsTable.php b/app/Filament/Resources/Clients/Tables/ClientsTable.php index 0821bc29..1d804696 100644 --- a/app/Filament/Resources/Clients/Tables/ClientsTable.php +++ b/app/Filament/Resources/Clients/Tables/ClientsTable.php @@ -2,10 +2,11 @@ namespace App\Filament\Resources\Clients\Tables; +use App\Actions\AlarmGenerator; +use App\Actions\MultilineGenerator; use App\Models\Bookmaker; use App\Models\Sport; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; +use Filament\Actions\Action; use Filament\Actions\EditAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; @@ -23,7 +24,7 @@ class ClientsTable ->formatStateUsing(fn (string $state): string => Bookmaker::where('id', $state)->pluck('name')->first()), TextColumn::make('sport') ->badge() - ->color('secondary') + ->color('warning') ->formatStateUsing(fn (string $state): string => Sport::where('id', $state)->pluck('name')->first()), TextColumn::make('created_at') ->dateTime() @@ -35,12 +36,19 @@ class ClientsTable ->toggleable(isToggledHiddenByDefault: true), ]) ->recordActions([ + Action::make('multiline') + ->icon('phosphor-gear-fine') + ->tooltip('Generates basic alarm configuration for client') + ->action(function ($record) { + MultilineGenerator::run($record); + }), + Action::make('alarm') + ->icon('phosphor-gear-fine') + ->tooltip('Generates basic multiline configuration for client') + ->action(function ($record) { + AlarmGenerator::run($record); + }), EditAction::make(), - ]) - ->toolbarActions([ - BulkActionGroup::make([ - DeleteBulkAction::make(), - ]), ]); } } diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 935366b1..368eb212 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -43,22 +43,27 @@ class EventsTable ->label('Event') ->icon(fn ($record) => $record->country->icon) ->description(fn ($record) => $record->competition_group->name), - TextColumn::make('home.name')->alignRight(), - TextColumn::make('away.name'), + TextColumn::make('home.name')->alignRight()->searchable(), + TextColumn::make('away.name')->searchable(), Odds3Way::make('odds_3way.bookmaker')->label('1X2'), ]) ->defaultSort('starttime', 'ASC') - // ->deferFilters(false) - // ->filters([ - // SelectFilter::make('sport_id') - // ->label('Sport') - // ->default(1) - // ->selectablePlaceholder(false) - // ->relationship('sport', 'name', fn (Builder $query) => $query->where('is_active', 1)) - // ->preload(), - // ], FiltersLayout::AboveContent) - // ->hiddenFilterIndicators() + ->deferFilters(false) + ->filters([ + SelectFilter::make('sport_id') + ->label('Sport') + ->default(1) + ->selectablePlaceholder(false) + ->relationship('sport', 'name', fn (Builder $query) => $query->where('is_active', 1)) + ->preload(), + // SelectFilter::make('competition_group_id') + // ->label('Tornament') + // ->options(fn () => Event::where('is_active', 1)->pluck('sport', 'id') + // ->relationship('sport', 'name', fn (Builder $query) => $query->where('is_active', 1)) + // ->preload(), + ], FiltersLayout::AboveContent) + ->hiddenFilterIndicators(false) ->persistFiltersInSession() ->recordActions([ // EditAction::make(), diff --git a/app/Filament/Resources/MultilineSettings/MultilineSettingResource.php b/app/Filament/Resources/MultilineSettings/MultilineSettingResource.php new file mode 100644 index 00000000..b0b4ee4f --- /dev/null +++ b/app/Filament/Resources/MultilineSettings/MultilineSettingResource.php @@ -0,0 +1,55 @@ + ListMultilineSettings::route('/'), + ]; + } + + public static function getNavigationBadge(): ?string + { + return parent::getEloquentQuery()->count(); + } +} diff --git a/app/Filament/Resources/MultilineSettings/Pages/CreateMultilineSetting.php b/app/Filament/Resources/MultilineSettings/Pages/CreateMultilineSetting.php new file mode 100644 index 00000000..216cd569 --- /dev/null +++ b/app/Filament/Resources/MultilineSettings/Pages/CreateMultilineSetting.php @@ -0,0 +1,11 @@ +components([ + TextInput::make('name')->required(), + TextInput::make('short')->required(), + TextInput::make('table')->required(), + Select::make('sport_id') + ->required() + ->label('Sport') + ->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id') + ->toArray()), + ]); + } +} diff --git a/app/Filament/Resources/MultilineSettings/Tables/MultilineSettingsTable.php b/app/Filament/Resources/MultilineSettings/Tables/MultilineSettingsTable.php new file mode 100644 index 00000000..b92f8273 --- /dev/null +++ b/app/Filament/Resources/MultilineSettings/Tables/MultilineSettingsTable.php @@ -0,0 +1,52 @@ +columns([ + IconColumn::make('sport.icon') + ->label('') + ->width('1rem') + ->icon(function ($record): string { + return $record->sport->icon; + }), + TextColumn::make('sport.name'), + TextColumn::make('name'), + TextColumn::make('short'), + TextColumn::make('table'), + TextColumn::make('rows'), + ]) + ->deferFilters(false) + ->filters([ + SelectFilter::make('sport_id') + ->label('Sport') + ->default(1) + ->selectablePlaceholder(false) + ->relationship('sport', 'name', fn (Builder $query) => $query->where('is_active', 1)) + ->preload(), + ], FiltersLayout::AboveContent) + ->hiddenFilterIndicators() + ->recordActions([ + EditAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); + } +} diff --git a/app/Filament/Resources/Multilines/Tables/MultilinesTable.php b/app/Filament/Resources/Multilines/Tables/MultilinesTable.php index c30d2759..84b62cd4 100644 --- a/app/Filament/Resources/Multilines/Tables/MultilinesTable.php +++ b/app/Filament/Resources/Multilines/Tables/MultilinesTable.php @@ -2,7 +2,6 @@ namespace App\Filament\Resources\Multilines\Tables; -use App\Actions\MultilineGenerator; use App\Filament\Tables\Columns\BookmakerIcon; use Filament\Actions\Action; use Filament\Tables\Columns\IconColumn; @@ -24,7 +23,7 @@ class MultilinesTable ->label($isReordering ? 'Disable reordering' : 'Enable reordering'), ) ->reorderable('sort') - ->defaultGroup('bettype.name') + ->defaultGroup('name') ->columns([ IconColumn::make('sport.icon') ->label('') @@ -32,9 +31,8 @@ class MultilinesTable ->icon(function ($record): string { return $record->sport->icon; }), - TextColumn::make('sport.name'), - TextColumn::make('matchpart.name'), - TextColumn::make('bettype.name'), + // TextColumn::make('sport.name'), + TextColumn::make('name'), TextColumn::make('bookmaker.name'), BookmakerIcon::make('bookmaker.icon')->label('Icon'), ]) @@ -49,13 +47,6 @@ class MultilinesTable ->preload(), ], FiltersLayout::AboveContent) ->hiddenFilterIndicators() - ->persistFiltersInSession() - ->headerActions([ - Action::make('generate') - ->icon('phosphor-gear-fine') - ->action(function () { - MultilineGenerator::run(); - }), - ]); + ->persistFiltersInSession(); } } diff --git a/app/Models/Multiline.php b/app/Models/Multiline.php index 5304df29..82f342ad 100644 --- a/app/Models/Multiline.php +++ b/app/Models/Multiline.php @@ -10,8 +10,9 @@ class Multiline extends Model protected $fillable = [ 'client_id', 'sport_id', - 'bettype_id', - 'matchpart_id', + 'table', + 'name', + 'disabled', 'bookmaker_id', 'sort', ]; @@ -21,16 +22,6 @@ class Multiline extends Model return $this->belongsTo(Sport::class); } - public function matchpart() - { - return $this->belongsTo(Matchpart::class); - } - - public function bettype() - { - return $this->belongsTo(Bettype::class); - } - public function bookmaker() { return $this->belongsTo(Bookmaker::class, 'bookmaker_id', 'txid'); diff --git a/app/Models/MultilineSetting.php b/app/Models/MultilineSetting.php new file mode 100644 index 00000000..af0e8638 --- /dev/null +++ b/app/Models/MultilineSetting.php @@ -0,0 +1,21 @@ +belongsTo(Sport::class); + } +} diff --git a/app/Models/Odds2wayS1.php b/app/Models/Odds2wayS1.php new file mode 100644 index 00000000..9ca0d26f --- /dev/null +++ b/app/Models/Odds2wayS1.php @@ -0,0 +1,49 @@ +belongsTo(Sport::class); + } + + public function bookmaker() + { + return $this->belongsTo(Bookmaker::class); + } + + public function event() + { + return $this->belongsTo(Event::class); + } + + public function provider() + { + return $this->belongsTo(Provider::class); + } +} diff --git a/app/Models/OddsHandicapQ1.php b/app/Models/OddsHandicapQ1.php new file mode 100644 index 00000000..aff3bd41 --- /dev/null +++ b/app/Models/OddsHandicapQ1.php @@ -0,0 +1,50 @@ +belongsTo(Sport::class); + } + + public function bookmaker() + { + return $this->belongsTo(Bookmaker::class); + } + + public function event() + { + return $this->belongsTo(Event::class); + } + + public function provider() + { + return $this->belongsTo(Provider::class); + } +} diff --git a/app/Models/OddsTotalQ1.php b/app/Models/OddsTotalQ1.php new file mode 100644 index 00000000..37432bb2 --- /dev/null +++ b/app/Models/OddsTotalQ1.php @@ -0,0 +1,50 @@ +belongsTo(Sport::class); + } + + public function bookmaker() + { + return $this->belongsTo(Bookmaker::class); + } + + public function event() + { + return $this->belongsTo(Event::class); + } + + public function provider() + { + return $this->belongsTo(Provider::class); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index d8b41dd9..b66bbf76 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Filament\Support\Colors\Color; use Filament\Support\Facades\FilamentColor; use Filament\Support\Facades\FilamentView; +use Filament\Tables\View\TablesRenderHook; use Filament\View\PanelsRenderHook; use Illuminate\Support\ServiceProvider; use Illuminate\View\View; @@ -27,7 +28,8 @@ class AppServiceProvider extends ServiceProvider public function boot(): void { FilamentView::registerRenderHook( - PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE, + // PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABS_END, + TablesRenderHook::TOOLBAR_SEARCH_AFTER, fn (): View => view('filament.hooks.table-bettype-filters'), scopes: [ ListEvents::class, diff --git a/database/migrations/2024_11_08_053430_create_odds_2ways_table_s1.php b/database/migrations/2024_11_08_053430_create_odds_2ways_table_s1.php new file mode 100644 index 00000000..84fe9a62 --- /dev/null +++ b/database/migrations/2024_11_08_053430_create_odds_2ways_table_s1.php @@ -0,0 +1,42 @@ +id(); + $table->foreignId('event_id')->constrained()->cascadeOnDelete(); + $table->integer('sport_id')->default(0); + $table->integer('bookmaker_id')->default(0); + $table->integer('provider_id')->default(0); + $table->bigInteger('offer_id')->default(0); + $table->string('bmoid')->nullable(); + $table->decimal('h2w', 7, 3)->default(0); + $table->decimal('a2w', 7, 3)->default(0); + $table->decimal('margin', 5, 1)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('nuh_check')->default(0); + $table->timestamp('last_check_at')->nullable(); + $table->timestamp('source_updated_at')->nullable(); + $table->timestamps(); + $table->index(['event_id']); + $table->index(['sport_id']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('odds_2ways_s1'); + } +}; diff --git a/database/migrations/2024_11_08_053439_create_odds_handicaps_table_q1.php b/database/migrations/2024_11_08_053439_create_odds_handicaps_table_q1.php new file mode 100644 index 00000000..21fd6169 --- /dev/null +++ b/database/migrations/2024_11_08_053439_create_odds_handicaps_table_q1.php @@ -0,0 +1,43 @@ +id(); + $table->foreignId('event_id')->constrained()->cascadeOnDelete(); + $table->integer('sport_id')->default(0); + $table->integer('bookmaker_id')->default(0); + $table->integer('provider_id')->default(0); + $table->bigInteger('offer_id')->default(0); + $table->string('bmoid')->nullable(); + $table->decimal('home', 7, 3)->default(0); + $table->decimal('away', 7, 3)->default(0); + $table->decimal('handicap', 7, 3)->default(0); + $table->decimal('margin', 5, 1)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('nuh_check')->default(0); + $table->timestamp('last_check_at')->nullable(); + $table->timestamp('source_updated_at')->nullable(); + $table->timestamps(); + $table->index(['event_id']); + $table->index(['sport_id']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('odds_handicaps_q1'); + } +}; diff --git a/database/migrations/2024_11_08_053445_create_odds_totals_table_q1.php b/database/migrations/2024_11_08_053445_create_odds_totals_table_q1.php new file mode 100644 index 00000000..f602512e --- /dev/null +++ b/database/migrations/2024_11_08_053445_create_odds_totals_table_q1.php @@ -0,0 +1,43 @@ +id(); + $table->foreignId('event_id')->constrained()->cascadeOnDelete(); + $table->integer('sport_id')->default(0); + $table->integer('bookmaker_id')->default(0); + $table->integer('provider_id')->default(0); + $table->bigInteger('offer_id')->default(0); + $table->string('bmoid')->nullable(); + $table->decimal('over', 7, 3)->default(0); + $table->decimal('under', 7, 3)->default(0); + $table->decimal('total', 7, 3)->default(0); + $table->decimal('margin', 5, 1)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('nuh_check')->default(0); + $table->timestamp('last_check_at')->nullable(); + $table->timestamp('source_updated_at')->nullable(); + $table->timestamps(); + $table->index(['event_id']); + $table->index(['sport_id']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('odds_totals_q1'); + } +}; diff --git a/database/migrations/2025_05_26_124609_create_multilines_table.php b/database/migrations/2025_05_26_124609_create_multilines_table.php index 9b7bc0a1..c73133c6 100644 --- a/database/migrations/2025_05_26_124609_create_multilines_table.php +++ b/database/migrations/2025_05_26_124609_create_multilines_table.php @@ -13,11 +13,12 @@ return new class extends Migration { Schema::create('multilines', function (Blueprint $table) { $table->id(); - $table->integer('sport_id'); $table->integer('client_id')->default(0); - $table->integer('bettype_id')->default(0); + $table->integer('sport_id'); + $table->boolean('disabled')->default(0); + $table->string('table')->nullable(); + $table->string('name')->nullable(); $table->integer('bookmaker_id')->default(0); - $table->integer('matchpart_id')->default(0); $table->integer('sort')->default(0); $table->timestamps(); }); diff --git a/database/migrations/2025_12_11_060528_create_bettypes_table.php b/database/migrations/2025_12_11_060528_create_bettypes_table.php index 4344cc44..08292cc8 100644 --- a/database/migrations/2025_12_11_060528_create_bettypes_table.php +++ b/database/migrations/2025_12_11_060528_create_bettypes_table.php @@ -17,6 +17,7 @@ return new class extends Migration $table->integer('bettype_id')->default(0); $table->string('name'); $table->text('oddsname'); + $table->boolean('disabled')->default(0); $table->boolean('can_odds_closed')->default(0); $table->boolean('is_spread')->default(0); $table->boolean('ft')->default(0); diff --git a/database/migrations/2025_12_14_090816_create_multiline_settings_table.php b/database/migrations/2025_12_14_090816_create_multiline_settings_table.php new file mode 100644 index 00000000..84e5089c --- /dev/null +++ b/database/migrations/2025_12_14_090816_create_multiline_settings_table.php @@ -0,0 +1,32 @@ +id(); + $table->integer('sport_id')->default(0); + $table->string('name'); + $table->string('short'); + $table->string('table'); + $table->integer('rows')->default(4); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('multiline_settings'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 98d9921b..140965b1 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -20,6 +20,7 @@ class DatabaseSeeder extends Seeder SportSeeder::class, SupervisorSeeder::class, BettypeSeeder::class, + MultilineSettingSeeder::class, ]); } } diff --git a/database/seeders/MultilineSettingSeeder.php b/database/seeders/MultilineSettingSeeder.php new file mode 100644 index 00000000..4287e6e3 --- /dev/null +++ b/database/seeders/MultilineSettingSeeder.php @@ -0,0 +1,39 @@ +*:nth-child(2) { + width: 100%; + justify-content: space-between; +} + .oddsbox .bl { border-left: 1px solid #e4e4e7; } diff --git a/resources/views/filament/hooks/table-bettype-filters.blade.php b/resources/views/filament/hooks/table-bettype-filters.blade.php index 3d5d245c..973b5b9b 100644 --- a/resources/views/filament/hooks/table-bettype-filters.blade.php +++ b/resources/views/filament/hooks/table-bettype-filters.blade.php @@ -1,38 +1,29 @@ -