default values service
This commit is contained in:
1 parent
24dbbd7fea
commit
fe7fc0accf
6 files changed
+115
-41
No files matched your search
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Services;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Console\Commands\Services\Tasks\CallTxoddsMarkets;
|
||||
use App\Console\Commands\Services\Tasks\DBMapper;
|
||||
use App\Console\Commands\Services\Tasks\GenerateDefaultSetting;
|
||||
|
||||
class Services
|
||||
{
|
||||
@@ -17,6 +18,10 @@ class Services
|
||||
case 'DB Mapper':
|
||||
DBMapper::run();
|
||||
break;
|
||||
case 'Generate Default Setting':
|
||||
GenerateDefaultSetting::run();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Services\Tasks;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\Client;
|
||||
use App\Models\MultilineClient;
|
||||
use App\Models\MultilineSetting;
|
||||
use App\Models\Sport;
|
||||
use App\Models\User;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class GenerateDefaultSetting
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('GENERATE DEFAULT SETTING', 'b');
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('1) multiline bookmaker slots for client', 'p');
|
||||
}
|
||||
|
||||
$sports = Sport::where('is_active', 1)->get();
|
||||
|
||||
$bookmaker = [0, 6, 30, 649, 117];
|
||||
|
||||
$clients = Client::get();
|
||||
|
||||
foreach ($clients as $client) {
|
||||
|
||||
foreach ($sports as $sport) {
|
||||
|
||||
$multilines = MultilineSetting::where('sport_id', $sport->id)->get();
|
||||
|
||||
foreach ($multilines as $multiline) {
|
||||
|
||||
for ($slot = 1; $slot <= 4; $slot++) {
|
||||
|
||||
MultilineClient::updateOrInsert(
|
||||
['client_id' => $client->id, 'sport_id' => $client->id, 'multiline_setting_id' => $multiline->id, 'position' => $slot],
|
||||
['bookmaker_id' => $bookmaker[$slot], '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]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user