Files
nuhodds_fi4/app/Console/Commands/Services/Tasks/DBMapper.php
T
2026-01-16 16:23:17 +01:00

67 lines
1.7 KiB
PHP

<?php
namespace App\Console\Commands\Services\Tasks;
use App\Console\Commands\Nuh;
use App\Console\Commands\Services\Tasks\Helper\FindCountry;
use App\Console\Commands\Services\Tasks\Helper\FindElement;
use App\Console\Commands\Services\Tasks\Helper\FindGroup;
use App\Models\Event;
use App\Models\Mapper;
use App\Utilities\Notice;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class DBMapper
{
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
if ($debug) {
Notice::note('MAPPER SOCCER', 'g');
}
$events = Mapper::get()->toArray();
$i = 0;
foreach ($events as $event) {
Notice::note($i);
FindElement::run($event);
FindGroup::run($event);
FindCountry::run($event);
// print_r($event);
if ($event['txodds_home_id'] && $event['txodds_away_id'] && $event['txodds_group_id']) {
$from = Carbon::createFromDate($event['starttime'])->subDay();
$to = Carbon::createFromDate($event['starttime'])->addDay();
// DB::enableQueryLog();
$query = Event::where('starttime', '>', $from->toDateTimeString())
->where('starttime', '<', $to->toDateTimeString())
->whereIn('home_id', $event['txodds_home_id'])
->whereIn('home_id', $event['txodds_away_id'])
->whereIn('competition_group_id', $event['txodds_group_id'])
->get();
// Notice::db(DB::getQueryLog());
Notice::db($query);
}
$i++;
if ($i > 100) {
exit;
}
}
}
}