diff --git a/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php b/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php index 91c4a79c..168c7957 100644 --- a/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php +++ b/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php @@ -4,9 +4,13 @@ namespace App\Console\Commands\Services\Tasks; use App\Console\Commands\Nuh; use App\Models\BettypeUser; +use App\Models\Bookmaker; use App\Models\Client; +use App\Models\ComparingBookmaker; use App\Models\MultilineClient; use App\Models\MultilineSetting; +use App\Models\Odds2way; +use App\Models\Odds3way; use App\Models\Sport; use App\Models\User; use App\Utilities\Notice; @@ -21,55 +25,97 @@ class GenerateDefaultSetting Notice::note('GENERATE DEFAULT SETTING', 'b'); } + // if ($debug) { + // Notice::note('1) multiline bookmaker slots for client', 'p'); + // } + + // $sports = Sport::where('is_active', 1)->pluck('id'); + + // $bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126]; + + // $clients = Client::get()->pluck('id'); + + // foreach ($clients as $client_id) { + + // foreach ($sports as $sport_id) { + + // $multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id'); + + // foreach ($multilines as $multiline_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] + // ); + // } + // } + // } + // } + + // if ($debug) { + // Notice::note('2) generator bettypes im comparatore for users', 'p'); + // } + + // $users = User::get(); + + // foreach ($users as $user) { + + // $multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', '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; + + // BettypeUser::firstOrCreate( + // ['sport_id' => $sport_id, 'user_id' => $user->id, 'multiline_setting_id' => $multiline_setting_id], + // ['is_active' => $is_active] + // ); + // } + // } + if ($debug) { - Notice::note('1) multiline bookmaker slots for client', 'p'); + Notice::note('3) comparing bookmaker', 'p'); } - $sports = Sport::where('is_active', 1)->pluck('id'); + $bookmakers = Bookmaker::where('is_active', 1)->pluck('id')->toArray(); - $bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126]; - - $clients = Client::get()->pluck('id'); - - foreach ($clients as $client_id) { + $res = Client::get(); + foreach ($res as $client) { + $client_bookmakers = $client->bookmaker; + $sports = $client->sport; foreach ($sports as $sport_id) { + switch ($sport_id) { + case 1: + $in_table_bookmaker = Odds3way::where('sport_id', $sport_id)->groupBy('bookmaker_id')->pluck('bookmaker_id')->toArray(); + break; + case 2: + case 3: + case 5: + $in_table_bookmaker = Odds2way::where('sport_id', $sport_id)->groupBy('bookmaker_id')->pluck('bookmaker_id')->toArray(); + break; + } - $multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id'); + foreach ($bookmakers as $sorting => $bookmaker_id) { - foreach ($multilines as $multiline_id) { + $is_hidden = \in_array($bookmaker_id, $in_table_bookmaker) ? 0 : 1; - foreach ($bookmaker_slots as $slot => $bookmaker_id) { + foreach ($client_bookmakers as $client_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] - ); + if ($client_bookmaker_id != $bookmaker_id) { + + for ($method_id = 1; $method_id <= 4; $method_id++) { + ComparingBookmaker::updateOrCreate( + ['method_id' => $method_id, 'sport_id' => $sport_id, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id], + ['is_hidden' => $is_hidden, 'is_active' => 1, 'sorting' => $sorting] + ); + } + } } } } } - - if ($debug) { - Notice::note('2) generator bettypes im comparatore for users', 'p'); - } - - $users = User::get(); - - foreach ($users as $user) { - - $multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', '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; - - BettypeUser::firstOrCreate( - ['sport_id' => $sport_id, 'user_id' => $user->id, 'multiline_setting_id' => $multiline_setting_id], - ['is_active' => $is_active] - ); - } - } - } } diff --git a/app/Livewire/ComparingBookmakerMenu.php b/app/Livewire/ComparingBookmakerMenu.php new file mode 100644 index 00000000..adbc618a --- /dev/null +++ b/app/Livewire/ComparingBookmakerMenu.php @@ -0,0 +1,70 @@ +description('Bookmaker higher up will be used first.') + ->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::make('middle')->action(fn () => $this->active_methode = 2) + ->color(fn () => $this->active_methode == 2 ? 'primary' : 'gray') + ->icon('phosphor-cell-signal-high'), + Action::make('low')->action(fn () => $this->active_methode = 3) + ->color(fn () => $this->active_methode == 3 ? 'primary' : 'gray') + ->icon('phosphor-cell-signal-medium'), + + ]) + ->query(ComparingBookmaker::query() + ->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)) + ->columns([ + TextColumn::make('id'), + ]) + ->paginated(false) + ->filters([ + // ... + ]) + ->recordActions([ + // ... + ]) + ->toolbarActions([ + // ... + ]); + } + + public function render(): View + { + return view('livewire.comparing-bookmaker-menu'); + } +} diff --git a/app/Livewire/ComparingMethod.php b/app/Livewire/ComparingMethod.php deleted file mode 100644 index a5366544..00000000 --- a/app/Livewire/ComparingMethod.php +++ /dev/null @@ -1,45 +0,0 @@ -query(Bookmaker::query()) - ->columns([ - TextColumn::make('name'), - ]) - ->filters([ - // ... - ]) - ->recordActions([ - // ... - ]) - ->toolbarActions([ - // ... - ]); - } - - public function render(): View - { - return view('livewire.comparing-method'); - } -} diff --git a/app/Models/ComparingBookmaker.php b/app/Models/ComparingBookmaker.php index 823ec569..3bc4cd7b 100644 --- a/app/Models/ComparingBookmaker.php +++ b/app/Models/ComparingBookmaker.php @@ -6,5 +6,15 @@ use Illuminate\Database\Eloquent\Model; class ComparingBookmaker extends Model { - // + protected $fillable = [ + 'method_id', + 'sport_id', + 'bookmaker_id', + 'client_bookmaker_id', + 'time_lastcheck', + 'margin_threshold', + 'is_active', + 'is_hidden', + 'sorting', + ]; } diff --git a/composer.lock b/composer.lock index 389b5a35..0ac3357d 100644 --- a/composer.lock +++ b/composer.lock @@ -12814,12 +12814,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.3" }, - "platform-dev": {}, - "plugin-api-version": "2.9.0" + "platform-dev": [], + "plugin-api-version": "2.6.0" } diff --git a/database/migrations/2026_01_17_163643_create_comparing_bookmakers_table.php b/database/migrations/2026_01_17_163643_create_comparing_bookmakers_table.php index be4cc044..f46a3284 100644 --- a/database/migrations/2026_01_17_163643_create_comparing_bookmakers_table.php +++ b/database/migrations/2026_01_17_163643_create_comparing_bookmakers_table.php @@ -14,13 +14,13 @@ return new class extends Migration Schema::create('comparing_bookmakers', function (Blueprint $table) { $table->id(); $table->integer('method_id'); - $table->string('method')->nullable(); $table->integer('sport_id')->index()->references('id')->on('sports'); $table->integer('bookmaker_id')->index()->references('id')->on('bookmakers'); - $table->integer('provider_id')->default(0)->nullable()->index()->references('id')->on('providers'); + $table->integer('client_bookmaker_id')->index()->references('id')->on('bookmakers'); $table->integer('time_lastcheck'); - $table->integer('margin_threshold'); + $table->decimal('margin_threshold', 3, 2)->default(0); $table->boolean('is_active')->default(false); + $table->boolean('is_hidden')->default(false); $table->integer('sorting')->nullable()->default(0); $table->timestamps(); }); diff --git a/resources/views/livewire/comparing-method.blade.php b/resources/views/livewire/comparing-bookmaker-menu.blade.php similarity index 80% rename from resources/views/livewire/comparing-method.blade.php rename to resources/views/livewire/comparing-bookmaker-menu.blade.php index c3fedc4a..0689aea9 100644 --- a/resources/views/livewire/comparing-method.blade.php +++ b/resources/views/livewire/comparing-bookmaker-menu.blade.php @@ -1,3 +1,3 @@