ComparingBookmakerMenu ok

This commit is contained in:
salam committed 2026-01-21 09:54:12 +01:00
1 parent be80128226
commit f59ac10c2a
17 files changed
+272 -317

No files matched your search

@@ -9,8 +9,6 @@ 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;
@@ -79,56 +77,59 @@ class GenerateDefaultSetting
Notice::note('3) comparing bookmaker', 'p');
}
$bookmakers = Bookmaker::get();
$res = Client::get();
$bookmakers_soccer = Bookmaker::where('in_soccer', 1)->orderBy('name')->pluck('id')->toArray();
ComparingBookmaker::where('method_id', 1)->where('sport_id', 1)->whereNotIn('bookmaker_id', $bookmakers_soccer)->delete();
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;
}
foreach ($client_bookmakers as $client_bookmaker_id) {
$i = 0;
foreach ($bookmakers as $bookmaker) {
$i = 1;
foreach ($bookmakers_soccer as $bookmaker_id) {
ComparingBookmaker::updateOrCreate(
['method_id' => 1, 'sport_id' => 1, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
);
$i++;
$is_hidden = \in_array($bookmaker->id, $in_table_bookmaker) ? 0 : 1;
}
}
}
foreach ($client_bookmakers as $client_bookmaker_id) {
$sports = Sport::getActiveSports();
if (($key = array_search(1, $sports)) !== false) {
unset($sports[$key]);
}
if ($client_bookmaker_id != $bookmaker->id) {
$bookmakers_other = Bookmaker::where('in_other', 1)->orderBy('name')->pluck('id')->toArray();
if ($bookmaker->is_active) {
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, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
);
}
} else {
for ($method_id = 1; $method_id <= 4; $method_id++) {
ComparingBookmaker::where('method_id', $method_id)
->where('sport_id', $sport_id)
->where('bookmaker_id', $bookmaker->id)
->where('client_bookmaker_id', $client_bookmaker_id)
->delete();
}
}
}
ComparingBookmaker::where('method_id', 1)->whereIn('sport_id', $sports)->whereNotIn('bookmaker_id', $bookmakers_other)->delete();
foreach ($res as $client) {
$client_bookmakers = $client->bookmaker;
foreach ($client_bookmakers as $client_bookmaker_id) {
foreach ($sports as $sport_id) {
$i = 1;
foreach ($bookmakers_other as $bookmaker_id) {
ComparingBookmaker::updateOrCreate(
['method_id' => 1, 'sport_id' => $sport_id, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
);
$i++;
}
}
}
}
}
}