wip del err

This commit is contained in:
salam committed 2026-10-04 15:22:39 +02:00
1 parent 812736ca9a
commit 9bcd4432c6
1210 files changed
-220941

No files matched your search

@@ -1,36 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
class AutoMapper
{
public static function switch()
{
$debug = Nuh::$options['d'] ?? 0;
switch (Nuh::$options['name']) {
case 'Bet365':
Bet365All::run();
break;
case 'MAGLOO KENIA':
MaglooKeniaAll::run();
break;
case 'MAGLOO NIGERIA':
MaglooNigeriaAll::run();
break;
case 'LOGIFUTURE NIGERA':
LogifutureNigeriaAll::run();
break;
case 'LOGIFUTURE COLOMBIA':
LogifutureColombiaAll::run();
break;
default:
Notice::note(Nuh::$options['name'].' '.Nuh::$options['sport'].' not implemented', 'r', 1);
break;
}
}
}
@@ -1,86 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper;
use App\Console\Commands\DbMapper\Helper\FindCompetitionGroup;
use App\Console\Commands\DbMapper\Helper\FindElement;
use App\Console\Commands\DbMapper\Store\StoreElement;
use App\Console\Commands\DbMapper\Store\StoreGroup;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use App\Utilities\Notice;
use Carbon\Carbon;
class Bet365All
{
/**
* Provider ID 2
*/
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
if ($debug) {
Notice::note(Nuh::$options['name'], 'g');
}
$sports = Sport::getActiveSports();
foreach ($sports as $sport_id) {
$mappers = Mapper::where('provider_id', 2)->where('sport_id', $sport_id)->where('starttime', '>=', Carbon::now())->where('starttime', '<', Carbon::now()->addDays(10))->get()->toArray();
foreach ($mappers as $mapper) {
FindElement::run($mapper);
FindCompetitionGroup::run($mapper);
if ($debug) {
Notice::note($mapper, 'b');
}
if ($mapper['txodds_home_id'] && $mapper['txodds_away_id'] && $mapper['txodds_group_id']) {
$from = Carbon::createFromDate($mapper['starttime'])->subDay();
$to = Carbon::createFromDate($mapper['starttime'])->addDay();
$event = Event::where('starttime', '>', $from)
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['txodds_group_id'])
->first();
if ($event) {
StoreElement::store($mapper);
StoreGroup::store($mapper);
$arr = [];
if ($mapper['bet365_id']) {
$arr['bet365_id'] = $mapper['bet365_id'];
}
if ($mapper['betradar_id']) {
$arr['betradar_id'] = $mapper['betradar_id'];
}
if ($mapper['betsapi_id']) {
$arr['betsapi_id'] = $mapper['betsapi_id'];
}
if ($arr) {
Event::where('id', $event->id)->update($arr);
Mapper::where('id', $mapper['id'])->delete();
}
if ($debug) {
Notice::note($event->toArray(), 'g');
}
}
}
}
}
}
}
@@ -1,53 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
class ArrayFunction
{
public static function remove($array, $value = [])
{
$tmp = str_replace(',', ' ', $str);
// $tmp = str_replace('-', ' ', $tmp);
$tmp = str_replace('/', ' ', $tmp);
$tmp = preg_replace('"\([^\)]*\)"', '', $tmp);
$tmp = preg_replace('/[^a-zA-Z0-9 ] /', '', $tmp);
$tmp = str_replace(' ', ' ', $tmp);
$elements = explode(' ', $tmp);
$_return = [];
foreach ($elements as $value) {
if (\strlen($value) > 3) {
$_return[] = $value;
}
}
usort($_return, function ($a, $b) {
return strlen($b) <=> strlen($a);
});
$remove = [
'fc',
'city',
'new',
'real',
'united',
'dinamo',
'town',
'club',
'union',
'sport',
'sports',
'basket',
'hapoel',
'maccabi',
'east'];
return array_diff($_return, $remove);
}
}
@@ -1,53 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
class ExplodeString
{
public static function grap($str)
{
$tmp = str_replace(',', ' ', $str);
// $tmp = str_replace('-', ' ', $tmp);
$tmp = str_replace('/', ' ', $tmp);
$tmp = preg_replace('"\([^\)]*\)"', '', $tmp);
$tmp = preg_replace('/[^a-zA-Z0-9 ] /', '', $tmp);
$tmp = str_replace(' ', ' ', $tmp);
$elements = explode(' ', $tmp);
$_return = [];
foreach ($elements as $value) {
if (\strlen($value) > 3) {
$_return[] = $value;
}
}
usort($_return, function ($a, $b) {
return strlen($b) <=> strlen($a);
});
$remove = [
'fc',
'city',
'new',
'real',
'united',
'dinamo',
'town',
'club',
'union',
'sport',
'sports',
'basket',
'hapoel',
'maccabi',
'east'];
return array_diff($_return, $remove);
}
}
@@ -1,28 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\CompetitionGroup;
use App\Models\CompetitionGroupProvider;
class FindCompetitionGroup
{
public static function run(&$mapper)
{
if (isset($mapper['group_id'])) {
$mapper['txodds_group_id'] = CompetitionGroupProvider::where('provider_id', $mapper['provider_id'])
->where('provider_group_id', $mapper['group_id'])->value('competition_group_id');
}
if (! $mapper['txodds_group_id']) {
$arr = ExplodeString::grap($mapper['group']);
$mapper['txodds_group_id'] = CompetitionGroup::where('sport_id', $mapper['sport_id'])
->where(function ($query) use ($arr) {
foreach ($arr as $str) {
$query->where('name', 'like', '%'.$str.'%');
}
})->value('id');
}
}
}
@@ -1,16 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\CompetitionGroupProvider;
class FindCompetitionGroupById
{
public static function run(&$mapper)
{
if (isset($mapper['group_id'])) {
$mapper['txodds_group_id'] = CompetitionGroupProvider::where('provider_id', $mapper['provider_id'])
->where('provider_group_id', $mapper['group_id'])->value('competition_group_id');
}
}
}
@@ -1,44 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\CountriesItalian;
use App\Models\Country;
class FindCountry
{
public static function run(&$event)
{
if ($event['provider_id'] == 10) {
// GOLDBET
$country = CountriesItalian::where('it', $event['country'])->value('en');
$event['txodds_country_id'] = Country::where('name', $country)->value('id');
} else {
$country = self::fix_country($event['country']);
$event['txodds_country_id'] = Country::where('name', $country)->value('id');
}
}
public static function fix_country($country)
{
switch ($country) {
case 'Internazionale':
case 'International Club':
case 'Internazionali Di Club':
case 'FIBA Intercontinental Cup':
return 'International';
case 'Euro Cup':
case 'Euro Cup Women':
case 'Euroleague':
case 'Euroleague Women':
return 'Europe';
case 'WNBA':
return 'USA';
default:
return $country;
}
}
}
@@ -1,42 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\Element;
use App\Models\ElementProvider;
class FindElement
{
public static function run(&$mapper)
{
if (isset($mapper['home_id']) && $mapper['home_id'] > 0) {
$mapper['txodds_home_id'] = ElementProvider::where('provider_id', $mapper['provider_id'])
->where('provider_element_id', $mapper['home_id'])->value('element_id');
}
if (! isset($mapper['txodds_home_id'])) {
$arr = ExplodeString::grap($mapper['home']);
$mapper['txodds_home_id'] = Element::where('sport_id', $mapper['sport_id'])
->where(function ($query) use ($arr) {
foreach ($arr as $str) {
$query->where('name', 'like', '%'.$str.'%');
}
})->value('id');
}
if (isset($mapper['away_id']) && $mapper['away_id'] > 0) {
$mapper['txodds_away_id'] = ElementProvider::where('provider_id', $mapper['provider_id'])
->where('provider_element_id', $mapper['away_id'])->value('element_id');
}
if (! isset($mapper['txodds_away_id'])) {
$arr = ExplodeString::grap($mapper['away']);
$mapper['txodds_away_id'] = Element::where('sport_id', $mapper['sport_id'])
->where(function ($query) use ($arr) {
foreach ($arr as $str) {
$query->where('name', 'like', '%'.$str.'%');
}
})->value('id');
}
}
}
@@ -1,21 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\ElementProvider;
class FindElementById
{
public static function run(&$mapper)
{
if (isset($mapper['home_id']) && $mapper['home_id'] > 0) {
$mapper['txodds_home_id'] = ElementProvider::where('provider_id', $mapper['provider_id'])
->where('provider_element_id', $mapper['home_id'])->value('element_id');
}
if (isset($mapper['away_id']) && $mapper['away_id'] > 0) {
$mapper['txodds_away_id'] = ElementProvider::where('provider_id', $mapper['provider_id'])
->where('provider_element_id', $mapper['away_id'])->value('element_id');
}
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\CompetitionGroupProvider;
use App\Models\Group;
class FindGroup
{
public static function run(&$mapper)
{
if (isset($mapper['group_id'])) {
$mapper['competition_group_id'] = CompetitionGroupProvider::where('provider_id', $mapper['provider_id'])
->where('provider_group_id', $mapper['group_id'])->value('competition_group_id');
}
if (! $mapper['competition_group_id']) {
$arr = ExplodeString::grap($mapper['group']);
$arr = array_diff($arr, ['Singles', 'ATP', 'WTA']);
$mapper['competition_group_id'] = Group::where('sport_id', $mapper['sport_id'])
->where('competition_group_id', '>', 0)
->where(function ($query) use ($arr) {
foreach ($arr as $str) {
$query->where('name', 'like', '%'.$str.'%');
}
})->value('competition_group_id');
}
}
}
@@ -1,80 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper;
use App\Console\Commands\DbMapper\Helper\FindCompetitionGroup;
use App\Console\Commands\DbMapper\Helper\FindElement;
use App\Console\Commands\DbMapper\Store\StoreElement;
use App\Console\Commands\DbMapper\Store\StoreGroup;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Utilities\Notice;
use Carbon\Carbon;
class LogifutureColombiaAll
{
/**
* Provider ID 2
*/
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
if ($debug) {
Notice::note(Nuh::$options['name'].' '.Nuh::$options['sport'], 'g');
}
$mappers = Mapper::where('provider_id', 2)->where('sport_id', 5)->where('starttime', '>=', Carbon::now())->get()->toArray();
foreach ($mappers as $mapper) {
FindElement::run($mapper);
FindCompetitionGroup::run($mapper);
if ($debug) {
Notice::note($mapper, 'b');
}
if ($mapper['txodds_home_id'] && $mapper['txodds_away_id'] && $mapper['txodds_group_id']) {
$from = Carbon::createFromDate($mapper['starttime'])->subDay();
$to = Carbon::createFromDate($mapper['starttime'])->addDay();
$event = Event::where('starttime', '>', $from)
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['txodds_group_id'])
->first();
if ($event) {
StoreElement::store($mapper);
StoreGroup::store($mapper);
$arr = [];
if ($mapper['bet365_id']) {
$arr['bet365_id'] = $mapper['bet365_id'];
}
if ($mapper['betradar_id']) {
$arr['betradar_id'] = $mapper['betradar_id'];
}
if ($mapper['betsapi_id']) {
$arr['betsapi_id'] = $mapper['betsapi_id'];
}
if ($arr) {
Event::where('id', $event->id)->update($arr);
Mapper::where('id', $mapper['id'])->delete();
}
if ($debug) {
Notice::note($event->toArray(), 'g');
}
}
}
}
}
}
@@ -1,94 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper;
use App\Console\Commands\DbMapper\Helper\FindElement;
use App\Console\Commands\DbMapper\Helper\FindGroup;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use App\Utilities\Notice;
use Carbon\Carbon;
class LogifutureNigeriaAll
{
/**
* Provider ID 5
* LOGIFUTURE NIGERA
*/
public static function run()
{
$provider_id = 5;
$debug = Nuh::$options['d'] ?? 0;
if ($debug) {
Notice::note(Nuh::$options['name'], 'g');
}
$sports = Sport::getActiveSports();
$found = [];
foreach ($sports as $sport_id) {
$mappers = Mapper::where('provider_id', $provider_id)->where('sport_id', $sport_id)->where('starttime', '>=', Carbon::now())->get()->toArray();
foreach ($mappers as $mapper) {
FindElement::run($mapper);
FindGroup::run($mapper);
if ($debug) {
Notice::note($mapper, 'p');
}
if (isset($mapper['txodds_home_id']) && isset($mapper['txodds_away_id']) && isset($mapper['competition_group_id'])) {
$from = Carbon::createFromDate($mapper['starttime'])->subDay();
$to = Carbon::createFromDate($mapper['starttime'])->addDay();
$event = Event::where('starttime', '>', $from)
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['competition_group_id'])
->first();
if ($event) {
if (! isset($found[$sport_id])) {
$found[$sport_id] = 1;
} else {
$found[$sport_id]++;
}
$arr = [];
if ($mapper['bet365_id']) {
$arr['bet365_id'] = $mapper['bet365_id'];
}
if ($mapper['betradar_id']) {
$arr['betradar_id'] = $mapper['betradar_id'];
}
if ($mapper['betsapi_id']) {
$arr['betsapi_id'] = $mapper['betsapi_id'];
}
if ($arr) {
Event::where('id', $event->id)->update($arr);
Mapper::where('id', $mapper['id'])->delete();
}
if ($debug) {
Notice::note($event->toArray(), 'g');
}
}
}
}
}
if ($debug) {
Notice::note($found, 'g');
}
}
}
@@ -1,100 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper;
use App\Console\Commands\DbMapper\Helper\FindCompetitionGroupById;
use App\Console\Commands\DbMapper\Helper\FindElementById;
use App\Console\Commands\DbMapper\Store\StoreElement;
use App\Console\Commands\DbMapper\Store\StoreGroup;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Utilities\Notice;
use Carbon\Carbon;
class MaglooKeniaAll
{
/**
* Provider Id 3
*/
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
$provider_id = 3;
if ($debug) {
Notice::note(Nuh::$options['name'], 'g');
}
$sports = [1, 3];
$found = [];
foreach ($sports as $sport_id) {
$mappers = Mapper::where('provider_id', $provider_id)->where('sport_id', $sport_id)->where('starttime', '>=', Carbon::now())->get()->toArray();
foreach ($mappers as $mapper) {
FindElementById::run($mapper);
FindCompetitionGroupById::run($mapper);
if ($debug) {
Notice::note($mapper, 'p');
}
if ($mapper['txodds_home_id'] && $mapper['txodds_away_id'] && $mapper['txodds_group_id']) {
$from = Carbon::createFromDate($mapper['starttime'])->subDay();
$to = Carbon::createFromDate($mapper['starttime'])->addDay();
$event = Event::where('starttime', '>', $from)
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['txodds_group_id'])
->first();
if ($event) {
if ($debug) {
Notice::note($event, 'g');
}
if (! isset($found[$sport_id])) {
$found[$sport_id] = 1;
} else {
$found[$sport_id]++;
}
StoreElement::store($mapper);
StoreGroup::store($mapper);
$arr = [];
if ($mapper['bet365_id']) {
$arr['bet365_id'] = $mapper['bet365_id'];
}
if ($mapper['betradar_id']) {
$arr['betradar_id'] = $mapper['betradar_id'];
}
if ($mapper['betsapi_id']) {
$arr['betsapi_id'] = $mapper['betsapi_id'];
}
if ($arr) {
Event::where('id', $event->id)->update($arr);
Mapper::where('id', $mapper['id'])->delete();
}
}
}
}
}
if ($debug) {
Notice::note($found, 'g');
}
}
}
@@ -1,100 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper;
use App\Console\Commands\DbMapper\Helper\FindCompetitionGroupById;
use App\Console\Commands\DbMapper\Helper\FindElementById;
use App\Console\Commands\DbMapper\Store\StoreElement;
use App\Console\Commands\DbMapper\Store\StoreGroup;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Utilities\Notice;
use Carbon\Carbon;
class MaglooNigeriaAll
{
/**
* Provider Id 4
*/
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
$provider_id = 4;
if ($debug) {
Notice::note(Nuh::$options['name'], 'g');
}
$sports = [1, 3];
$found = [];
foreach ($sports as $sport_id) {
$mappers = Mapper::where('provider_id', $provider_id)->where('sport_id', $sport_id)->where('starttime', '>=', Carbon::now())->get()->toArray();
foreach ($mappers as $mapper) {
FindElementById::run($mapper);
FindCompetitionGroupById::run($mapper);
if ($debug) {
Notice::note($mapper, 'p');
}
if ($mapper['txodds_home_id'] && $mapper['txodds_away_id'] && $mapper['txodds_group_id']) {
$from = Carbon::createFromDate($mapper['starttime'])->subDay();
$to = Carbon::createFromDate($mapper['starttime'])->addDay();
$event = Event::where('starttime', '>', $from)
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['txodds_group_id'])
->first();
if ($event) {
if ($debug) {
Notice::note($event, 'g');
}
if (! isset($found[$sport_id])) {
$found[$sport_id] = 1;
} else {
$found[$sport_id]++;
}
StoreElement::store($mapper);
StoreGroup::store($mapper);
$arr = [];
if ($mapper['bet365_id']) {
$arr['bet365_id'] = $mapper['bet365_id'];
}
if ($mapper['betradar_id']) {
$arr['betradar_id'] = $mapper['betradar_id'];
}
if ($mapper['betsapi_id']) {
$arr['betsapi_id'] = $mapper['betsapi_id'];
}
if ($arr) {
Event::where('id', $event->id)->update($arr);
Mapper::where('id', $mapper['id'])->delete();
}
}
}
}
}
if ($debug) {
Notice::note($found, 'g');
}
}
}
@@ -1,30 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Store;
use App\Models\ElementProvider;
class StoreElement
{
public static function store(&$mapper)
{
$home = [];
$home['sport_id'] = $mapper['sport_id'];
$home['element_id'] = $mapper['txodds_home_id'];
$home['provider_id'] = $mapper['provider_id'];
$home['add_by_method_id'] = 3;
$home['name'] = $mapper['home'];
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper['home_id']], $home);
$away = [];
$away['sport_id'] = $mapper['sport_id'];
$away['element_id'] = $mapper['txodds_away_id'];
$away['provider_id'] = $mapper['provider_id'];
$home['add_by_method_id'] = 3;
$away['name'] = $mapper['away'];
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper['away_id']], $away);
}
}
@@ -1,20 +0,0 @@
<?php
namespace App\Console\Commands\DbMapper\Store;
use App\Models\CompetitionGroupProvider;
class StoreGroup
{
public static function store(&$mapper)
{
$group = [];
$group['sport_id'] = $mapper['sport_id'];
$group['competition_group_id'] = $mapper['txodds_group_id'];
$group['provider_id'] = $mapper['provider_id'];
$home['add_by_method_id'] = 3;
$group['name'] = $mapper['group'];
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $mapper['group_id']], $group);
}
}