89 lines
3.7 KiB
PHP
89 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Models\Bookmaker;
|
|
use App\Models\ClientBookmaker;
|
|
use App\Models\Provider;
|
|
use App\Models\Sport;
|
|
use App\Models\Supervisor;
|
|
|
|
class SupervisorDb
|
|
{
|
|
public static function generate($command)
|
|
{
|
|
return;
|
|
$_client_bookmaker = ClientBookmaker::get()->all();
|
|
$_provider = Provider::get()->all();
|
|
$_sports = Sport::where('is_active', 1)->get()->all();
|
|
$_bookmaker = Bookmaker::where('is_active', 1)->get()->all();
|
|
|
|
$processes = Supervisor::where('command', $command)->get()->all();
|
|
|
|
$have = [];
|
|
foreach ($processes as $process) {
|
|
|
|
dd($process);
|
|
|
|
$have[] = $process['code'];
|
|
|
|
$tmp = [];
|
|
$tmp['process'] = $process->command;
|
|
|
|
if (! $process->per_sport && ! $process->per_client) {
|
|
// $tmp['code'] = $row->command.$row->process;
|
|
// $tmp['command'] = $row->command.' '.$row->process;
|
|
// $tmp['description'] = $row->description;
|
|
// $res = Supervisor::where('code', $tmp['code'])->get();
|
|
// if (! $res->count()) {
|
|
// Supervisor::insert($tmp);
|
|
// }
|
|
|
|
} elseif ($process->per_sport && ! $process->per_client) {
|
|
foreach ($sports as $sport) {
|
|
$tmp['command'] = $process->process.$sport->code;
|
|
$tmp['sport_id'] = $sport->id;
|
|
$tmp['description'] = $process->description.' '.$sport->sport;
|
|
Supervisor::updateOrCreate(
|
|
['code' => $process->command.$sport->code, 'sport_id' => $sport->id],
|
|
['command' => $process->process.$sport->code, 'description' => $process->description]
|
|
);
|
|
}
|
|
|
|
// } elseif (! $row->per_sport && $row->per_client) {
|
|
// foreach ($clients as $client) {
|
|
|
|
// $tmp['customer_id'] = $client->id;
|
|
// if ($row->command == 'sen') {
|
|
// $tmp['code'] = $row->command.$row->process.$client->id;
|
|
// $tmp['command'] = $row->command.' '.$row->process.' '.$client->id;
|
|
// } else {
|
|
// $tmp['code'] = $row->command.$client->id;
|
|
// $tmp['command'] = $row->command.' '.$client->id;
|
|
// }
|
|
// $tmp['description'] = $row->description.' '.$client->customer;
|
|
// $res = Supervisor::where('code', $tmp['code'])->get();
|
|
// if (! $res->count()) {
|
|
// Supervisor::insert($tmp);
|
|
// }
|
|
// }
|
|
// } else {
|
|
// foreach ($sports as $sport) {
|
|
// foreach ($clients as $client) {
|
|
// $tmp['sport_id'] = $sport->id;
|
|
// $tmp['customer_id'] = $client->id;
|
|
// $tmp['code'] = $row->command.$sport->code.$client->id;
|
|
// $tmp['command'] = $row->command.' '.$sport->code.' '.$client->id;
|
|
// $tmp['description'] = $row->description.' '.$client->customer.' '.$sport->sport;
|
|
// $res = Supervisor::where('code', $tmp['code'])->get();
|
|
// if (! $res->count()) {
|
|
// Supervisor::insert($tmp);
|
|
// }
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
Supervisor::where('process', $command)->whereNotIn('code', $have)->delete();
|
|
}
|
|
}
|