default values service
This commit is contained in:
1 parent
24dbbd7fea
commit
fe7fc0accf
6 files changed
+115
-41
No files matched your search
@@ -5,7 +5,6 @@ namespace App\Actions;
|
||||
use App\Models\MultilineClient;
|
||||
use App\Models\MultilineSetting;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MultilineGenerator
|
||||
{
|
||||
@@ -25,17 +24,10 @@ class MultilineGenerator
|
||||
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
|
||||
$setting = [];
|
||||
$setting['client_id'] = $client_id;
|
||||
$setting['sport_id'] = $sport_id;
|
||||
$setting['multiline_setting_id'] = $multiline->id;
|
||||
$setting['position'] = $i;
|
||||
|
||||
DB::table('multiline_clients')->updateOrInsert($setting, [
|
||||
'bookmaker_id' => $bookmaker[$i],
|
||||
'sort' => $i,
|
||||
'disabled' => 0,
|
||||
]);
|
||||
MultilineClient::updateOrInsert(
|
||||
['client_id' => $client_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline->id, 'position' => $i],
|
||||
['bookmaker_id' => $bookmaker[$i], 'sort' => $i, 'disabled' => 0]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ class SupervisorsTable
|
||||
return [
|
||||
'Txodds Markets' => 'Txodds Markets',
|
||||
'DB Mapper' => 'DB Mapper',
|
||||
'Generate Default Setting' => 'Generate Default Setting',
|
||||
];
|
||||
case 9:
|
||||
case 10:
|
||||
|
||||
Reference in new issue
Block a user