bookmaker comaring wip
This commit is contained in:
1 parent
d351e6fb60
commit
d07277ae06
8 files changed
+171
-90
No files matched your search
@@ -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]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\ComparingBookmaker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ComparingBookmakerMenu extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $active_methode = 1;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->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');
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Bookmaker;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ComparingMethod extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(Bookmaker::query())
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
])
|
||||
->filters([
|
||||
// ...
|
||||
])
|
||||
->recordActions([
|
||||
// ...
|
||||
])
|
||||
->toolbarActions([
|
||||
// ...
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.comparing-method');
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
Generated
+3
-3
@@ -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"
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
<div>
|
||||
{{ $this->table }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -199,7 +199,7 @@
|
||||
Comparing Bookmaker
|
||||
</x-slot>
|
||||
|
||||
@livewire('comparing-method')
|
||||
@livewire('comparing-bookmaker-menu')
|
||||
|
||||
</x-filament::modal>
|
||||
@endif
|
||||
|
||||
Reference in new issue
Block a user