add groups and major groups direct from txodds for auto mapping names

This commit is contained in:
salam committed 2026-02-25 19:50:40 +01:00
1 parent ba83e1a12d
commit 859038cc8c
21 files changed
+299 -40

No files matched your search

@@ -0,0 +1,53 @@
<?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);
}
}
@@ -0,0 +1,28 @@
<?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');
}
}
}
@@ -2,8 +2,8 @@
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\CompetitionGroup;
use App\Models\CompetitionGroupProvider;
use App\Models\Group;
class FindGroup
{
@@ -17,12 +17,16 @@ class FindGroup
if (! $mapper['txodds_group_id']) {
$arr = ExplodeString::grap($mapper['group']);
$mapper['txodds_group_id'] = CompetitionGroup::where('sport_id', $mapper['sport_id'])
$arr = array_diff($arr, ['Singles', 'ATP', 'WTA']);
print_r($arr);
$mapper['competition_group_id'] = Group::where('sport_id', $mapper['sport_id'])
->where(function ($query) use ($arr) {
foreach ($arr as $str) {
$query->where('name', 'like', '%'.$str.'%');
}
})->value('id');
})->value('competition_group_id');
}
}
}