This commit is contained in:
salam committed 2025-12-16 15:52:07 +01:00
1 parent 391bd1d1f3
commit 26bf5359bc
14 files changed
+256 -235

No files matched your search

+24 -221
View File
@@ -4,6 +4,10 @@ namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Grapper\TxOdds\Odds\_3Way; use App\Console\Commands\Grapper\TxOdds\Odds\_3Way;
use App\Console\Commands\Grapper\TxOdds\Odds\_Dc; use App\Console\Commands\Grapper\TxOdds\Odds\_Dc;
use App\Console\Commands\Grapper\TxOdds\Odds\_Dnb;
use App\Console\Commands\Grapper\TxOdds\Odds\_Ggng;
use App\Console\Commands\Grapper\TxOdds\Odds\_Totals;
use App\Console\Commands\Grapper\TxOdds\Odds\_Tq;
use App\Console\Commands\NuhBash; use App\Console\Commands\NuhBash;
use App\Console\Commands\Xml; use App\Console\Commands\Xml;
use App\Models\CompetitionGroup; use App\Models\CompetitionGroup;
@@ -11,12 +15,6 @@ use App\Models\Element;
use App\Models\Event; use App\Models\Event;
use App\Models\EventBookmaker; use App\Models\EventBookmaker;
use App\Models\Group; use App\Models\Group;
use App\Models\Odds2way;
use App\Models\Odds3way;
use App\Models\OddsDc;
use App\Models\OddsGgng;
use App\Models\OddsQualify;
use App\Models\OddsTotal;
use App\Utilities\Notice; use App\Utilities\Notice;
use Carbon\Carbon; use Carbon\Carbon;
@@ -59,6 +57,7 @@ class Odds
11534337 GG/NG (both teams to score) 11534337 GG/NG (both teams to score)
5242880 DOUBLE CHANCE 5242880 DOUBLE CHANCE
7340033 TO PROGRESS (to_qualify) 7340033 TO PROGRESS (to_qualify)
6291457 DRAW NO BET
Not used: Not used:
@@ -71,7 +70,6 @@ class Odds
2097153 ODD / EVEN 2097153 ODD / EVEN
4194304 TOTAL GOALS 4194304 TOTAL GOALS
6291457 DRAW NO BET
8388608 1X2 EURO HANDCIAP 8388608 1X2 EURO HANDCIAP
9437188 TOTAL CORNERS 9437188 TOTAL CORNERS
9502724 TOTAL CORNERS 1ST HALF 9502724 TOTAL CORNERS 1ST HALF
@@ -85,7 +83,7 @@ class Odds
switch (NuhBash::$options['sport_id']) { switch (NuhBash::$options['sport_id']) {
case 1: case 1:
$markets = '0,4,11534337,5242880,7340033'; $markets = '0,4,11534337,5242880,7340033,6291457';
break; break;
case 2: case 2:
// needs check // needs check
@@ -184,7 +182,10 @@ class Odds
foreach ($row->bookmaker as $book) { foreach ($row->bookmaker as $book) {
$odds = []; $odds = [];
$odds['event_id'] = NuhBash::$_event->id;
$odds['bookmaker_id'] = (int) $book['bid']; $odds['bookmaker_id'] = (int) $book['bid'];
$odds['sport_id'] = (int) $event['sport_id'];
$odds['provider_id'] = 2;
NuhBash::$_event_bookmaker = []; NuhBash::$_event_bookmaker = [];
@@ -209,15 +210,25 @@ class Odds
} }
} }
Notice::note($bettypeid, 'b');
switch ($bettypeid) { switch ($bettypeid) {
case 0: case 0:
_3Way::grap($odds, $offer); _3Way::grap($odds, $offer);
break; break;
case 4:
_Totals::grap($odds, $offer);
break;
case 5242880: case 5242880:
_Dc::grap($odds, $offer); _Dc::grap($odds, $offer);
break; break;
case 6291457:
_Dnb::grap($odds, $offer);
break;
case 11534337:
_Ggng::grap($odds, $offer);
break;
case 7340033:
_Tq::grap($odds, $offer);
break;
default: default:
Notice::note('ERROR Bettype ID not set: '.$bettypeid, 'r'); Notice::note('ERROR Bettype ID not set: '.$bettypeid, 'r');
@@ -227,10 +238,6 @@ class Odds
foreach (NuhBash::$_event_bookmaker as $value) { foreach (NuhBash::$_event_bookmaker as $value) {
if ($debug) {
Notice::note('Event Bookmaker', 'b');
}
EventBookmaker::updateOrCreate([ EventBookmaker::updateOrCreate([
'event_id' => NuhBash::$_event->id, 'event_id' => NuhBash::$_event->id,
'bookmaker_id' => $odds['bookmaker_id'], 'bookmaker_id' => $odds['bookmaker_id'],
@@ -244,213 +251,9 @@ class Odds
} }
} }
// foreach ($json_obj['match'] as $match) { if ($debug) {
Notice::note('END', 'g', 1);
// self::$event = []; }
// foreach ($match as $key => $v) {
// // if ($debug) {
// // Notice::note($key, 'b');
// // }
// switch ($key) {
// case '@attributes':
// self::$event['id'] = (int) $v['id'];
// break;
// case 'time':
// self::$event['starttime'] = Carbon::createFromDate($v)->toDateTimeString();
// break;
// case 'group':
// self::$event['sport_id'] = (int) $v['@attributes']['spid'];
// self::$event['country_id'] = (int) $v['@attributes']['cnid'];
// self::$event['group_id'] = (int) $v['@attributes']['id'];
// self::$event['competition_group_id'] = (int) $v['@attributes']['cgid'];
// break;
// case 'hteam':
// self::$event['home_id'] = $v['@attributes']['id'];
// break;
// case 'ateam':
// self::$event['away_id'] = $v['@attributes']['id'];
// break;
// case 'bookmaker':
// Event::updateOrCreate(self::$event, ['starttime' => self::$event['starttime']]);
// Notice::note(count($v), 'r');
// if (count($v) <= 2) {
// $bkmid = (int) $v['@attributes']['bid'];
// Notice::note($v, 'p');
// } else {
// foreach ($v as $books) {
// Notice::note($books, 'b');
// $bkmid = (int) $books['@attributes']['bid'];
// // foreach ($books['offer'] as $bk => $book) {
// // if ($bkmid) {
// // foreach ($book as $type => $od) {
// // switch ($type) {
// // case '@attributes':
// // $bettypeid = (int) $od['ot'];
// // $bmoid = (int) $od['bmoid'];
// // break;
// // case 'odds':
// // switch ($bettypeid) {
// // case '0':
// // Odds3way::updateOrCreate(
// // [
// // 'event_id' => $event->id,
// // 'bookmaker_id' => $bkmid,
// // 'sport_id' => NuhBash::$options['sport_id'],
// // ],
// // [
// // 'h3w' => (float) $od['o1'],
// // 'd3w' => (float) $od['o2'],
// // 'a3w' => (float) $od['o3'],
// // 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
// // 'flag' => 1,
// // 'nuh_check' => 0,
// // 'source_updated_at' => $od['@attributes']['time'],
// // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // ]
// // );
// // EventBookmaker::updateOrCreate([
// // 'event_id' => $event->id,
// // 'bookmaker_id' => $bkmid,
// // 'bmoid' => $bmoid,
// // ], [
// // 'bkm_starttime' => Carbon::createFromDate($od['@attributes']['starting_time'])->toDateTimeString(),
// // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // ]);
// // break;
// // // case '1':
// // // Odds2way::updateOrCreate(
// // // [
// // // 'event_id' => $event->id,
// // // 'bookmaker_id' => $bkmid,
// // // 'sport_id' => NuhBash::$options['sport_id'],
// // // ],
// // // [
// // // 'h2w' => (float) $od['o1'],
// // // 'a2w' => (float) $od['o3'],
// // // 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
// // // 'flag' => 1,
// // // 'nuh_check' => 0,
// // // 'source_updated_at' => $od['@attributes']['time'],
// // // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // // ]
// // // );
// // // break;
// // // case '4':
// // // OddsTotal::updateOrCreate(
// // // [
// // // 'event_id' => $event->id,
// // // 'bookmaker_id' => $bkmid,
// // // 'sport_id' => NuhBash::$options['sport_id'],
// // // 'spread' => (float) $od['o3'],
// // // ],
// // // [
// // // 'over' => (float) $od['o1'],
// // // 'under' => (float) $od['o2'],
// // // 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
// // // 'flag' => 1,
// // // 'nuh_check' => 0,
// // // 'source_updated_at' => $od['@attributes']['time'],
// // // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // // ]
// // // );
// // // break;
// // // case '5242880':
// // // OddsDc::updateOrCreate(
// // // [
// // // 'event_id' => $event->id,
// // // 'bookmaker_id' => $bkmid,
// // // 'sport_id' => NuhBash::$options['sport_id'],
// // // ],
// // // [
// // // 'dc1x' => (float) $od['o1'],
// // // 'dc12' => (float) $od['o2'],
// // // 'dc2x' => (float) $od['o3'],
// // // 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
// // // 'flag' => 1,
// // // 'nuh_check' => 0,
// // // 'source_updated_at' => $od['@attributes']['time'],
// // // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // // ]
// // // );
// // // break;
// // // case '11534337':
// // // OddsGgng::updateOrCreate(
// // // [
// // // 'event_id' => $event->id,
// // // 'bookmaker_id' => $bkmid,
// // // 'sport_id' => NuhBash::$options['sport_id'],
// // // ],
// // // [
// // // 'gg' => (float) $od['o1'],
// // // 'ng' => (float) $od['o3'],
// // // 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
// // // 'flag' => 1,
// // // 'nuh_check' => 0,
// // // 'source_updated_at' => $od['@attributes']['time'],
// // // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // // ]
// // // );
// // // break;
// // // case '11534337':
// // // OddsQualify::updateOrCreate(
// // // [
// // // 'event_id' => $event->id,
// // // 'bookmaker_id' => $bkmid,
// // // 'sport_id' => NuhBash::$options['sport_id'],
// // // ],
// // // [
// // // 'htq' => (float) $od['o1'],
// // // 'atq' => (float) $od['o2'],
// // // 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
// // // 'flag' => 1,
// // // 'nuh_check' => 0,
// // // 'source_updated_at' => $od['@attributes']['time'],
// // // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // // ]
// // // );
// // // break;
// // }
// // break;
// // }
// // }
// // break;
// // }
// // }
// }
// break;
// }
// }
// }
// Notice::note('END', 'r', 1);
// }
} }
} }
} }
@@ -16,7 +16,7 @@ class _3Way
$debug = NuhBash::$options['d'] ?? 0; $debug = NuhBash::$options['d'] ?? 0;
if ($debug) { if ($debug) {
Notice::note('Odds 3 Way', 'b'); Notice::note('1X2 '.$odds['bookmaker_id'], 'b');
} }
$update_array = []; $update_array = [];
@@ -41,9 +41,6 @@ class _3Way
$update_array['last_check_at'] = Carbon::now()->toDateTimeString(); $update_array['last_check_at'] = Carbon::now()->toDateTimeString();
$update_array['source_updated_at'] = $odds['source_updated_at']; $update_array['source_updated_at'] = $odds['source_updated_at'];
Odds3way::updateOrCreate([ Odds3way::updateOrCreate($odds, $update_array);
'event_id' => NuhBash::$_event->id,
'bookmaker_id' => $odds['bookmaker_id'],
], $update_array);
} }
} }
@@ -15,7 +15,7 @@ class _Dc
$debug = NuhBash::$options['d'] ?? 0; $debug = NuhBash::$options['d'] ?? 0;
if ($debug) { if ($debug) {
Notice::note('Double Chance', 'b'); Notice::note('Double Chance '.$odds['bookmaker_id'], 'b');
} }
$update_array = []; $update_array = [];
@@ -33,9 +33,6 @@ class _Dc
$update_array['last_check_at'] = Carbon::now()->toDateTimeString(); $update_array['last_check_at'] = Carbon::now()->toDateTimeString();
$update_array['source_updated_at'] = $odds['source_updated_at']; $update_array['source_updated_at'] = $odds['source_updated_at'];
OddsDc::updateOrCreate([ OddsDc::updateOrCreate($odds, $update_array);
'event_id' => NuhBash::$_event->id,
'bookmaker_id' => $odds['bookmaker_id'],
], $update_array);
} }
} }
@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\NuhBash;
use App\Models\OddsDnb;
use App\Utilities\Margin;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class _Dnb
{
public static function grap($odds, $offer)
{
$debug = NuhBash::$options['d'] ?? 0;
if ($debug) {
Notice::note('Draw No Bet '.$odds['bookmaker_id'], 'b');
}
$update_array = [];
foreach ($offer as $value) {
$update_array['dnb1'] = (float) $value->o1;
$update_array['dnb2'] = (float) $value->o3;
}
$update_array['margin'] = (float) Margin::calculate($update_array, 1);
$update_array['bmoid'] = $odds['bmoid'];
$update_array['offer_id'] = $odds['offer_id'];
$update_array['flag'] = 1;
$update_array['nuh_check'] = 0;
$update_array['last_check_at'] = Carbon::now()->toDateTimeString();
$update_array['source_updated_at'] = $odds['source_updated_at'];
OddsDnb::updateOrCreate($odds, $update_array);
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\NuhBash;
use App\Models\OddsGgng;
use App\Utilities\Margin;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class _Ggng
{
public static function grap($odds, $offer)
{
$debug = NuhBash::$options['d'] ?? 0;
if ($debug) {
Notice::note('Goal No Goal '.$odds['bookmaker_id'], 'b');
}
$update_array = [];
foreach ($offer as $value) {
$update_array['gg'] = (float) $value->o1;
$update_array['ng'] = (float) $value->o3;
}
$update_array['margin'] = (float) Margin::calculate($update_array, 1);
$update_array['bmoid'] = $odds['bmoid'];
$update_array['offer_id'] = $odds['offer_id'];
$update_array['flag'] = 1;
$update_array['nuh_check'] = 0;
$update_array['last_check_at'] = Carbon::now()->toDateTimeString();
$update_array['source_updated_at'] = $odds['source_updated_at'];
OddsGgng::updateOrCreate($odds, $update_array);
}
}
@@ -0,0 +1,46 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\NuhBash;
use App\Models\OddsTotal;
use App\Utilities\Margin;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class _Totals
{
public static function grap($odds, $offer)
{
$debug = NuhBash::$options['d'] ?? 0;
if ($debug) {
Notice::note('Totals '.$odds['bookmaker_id'], 'b');
}
$update_array = [];
foreach ($offer as $value) {
$update_array['over'] = (float) $value->o1;
$update_array['under'] = (float) $value->o2;
$update_array['total'] = (float) $value->o3;
}
if ($odds['sport_id'] == 1) {
if ((float) $update_array['total'] != 2.5) {
return;
}
}
$update_array['margin'] = (float) Margin::calculate([$update_array['over'], $update_array['under']], 1);
$update_array['bmoid'] = $odds['bmoid'];
$update_array['offer_id'] = $odds['offer_id'];
$update_array['flag'] = 1;
$update_array['nuh_check'] = 0;
$update_array['last_check_at'] = Carbon::now()->toDateTimeString();
$update_array['source_updated_at'] = $odds['source_updated_at'];
OddsTotal::updateOrCreate($odds, $update_array);
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\NuhBash;
use App\Models\OddsQualify;
use App\Utilities\Margin;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class _Tq
{
public static function grap($odds, $offer)
{
$debug = NuhBash::$options['d'] ?? 0;
if ($debug) {
Notice::note('To Qualify '.$odds['bookmaker_id'], 'b');
}
$update_array = [];
foreach ($offer as $value) {
$update_array['hta'] = (float) $value->o1;
$update_array['atq'] = (float) $value->o3;
}
$update_array['margin'] = (float) Margin::calculate($update_array, 1);
$update_array['bmoid'] = $odds['bmoid'];
$update_array['offer_id'] = $odds['offer_id'];
$update_array['flag'] = 1;
$update_array['nuh_check'] = 0;
$update_array['last_check_at'] = Carbon::now()->toDateTimeString();
$update_array['source_updated_at'] = $odds['source_updated_at'];
OddsQualify::updateOrCreate($odds, $update_array);
}
}
@@ -3,6 +3,7 @@
namespace App\Filament\Resources\Events\Tables; namespace App\Filament\Resources\Events\Tables;
use App\Filament\Tables\Columns\Odds3Way; use App\Filament\Tables\Columns\Odds3Way;
use App\Filament\Tables\Columns\OddsTotals;
use Carbon\Carbon; use Carbon\Carbon;
use Filament\Actions\DeleteAction; use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction; use Filament\Actions\EditAction;
@@ -26,7 +27,7 @@ class EventsTable
->size(IconSize::ExtraLarge) ->size(IconSize::ExtraLarge)
->icon(fn ($record) => $record->sport->icon) ->icon(fn ($record) => $record->sport->icon)
->tooltip(fn ($record) => $record->id), ->tooltip(fn ($record) => $record->id),
TextColumn::make('txodds_id')->label('Match Id')->badge()->copyable(), TextColumn::make('txodds_id')->label('Match Id')->badge()->copyable()->searchable(),
TextColumn::make('starttime') TextColumn::make('starttime')
->label('Start') ->label('Start')
->alignCenter() ->alignCenter()
@@ -41,7 +42,8 @@ class EventsTable
TextColumn::make('home.name')->alignRight()->searchable(), TextColumn::make('home.name')->alignRight()->searchable(),
TextColumn::make('away.name')->searchable(), TextColumn::make('away.name')->searchable(),
Odds3Way::make('odds_3way.bookmaker')->label('Market')->visible(auth()->user()->multiline_setting_id == 1), Odds3Way::make('odds_3way.bookmaker')->label('1X2')->visible(auth()->user()->multiline_setting_id == 1),
OddsTotals::make('odds_totals.bookmaker')->label('Totals')->visible(auth()->user()->multiline_setting_id == 6),
]) ])
->defaultSort('starttime', 'ASC') ->defaultSort('starttime', 'ASC')
->deferFilters(false) ->deferFilters(false)
@@ -23,6 +23,12 @@ class MultilineClientResources extends Resource
// protected static string|\UnitEnum|null $navigationGroup = 'Settings'; // protected static string|\UnitEnum|null $navigationGroup = 'Settings';
protected static ?string $navigationLabel = 'Multiline';
protected static ?string $modelLabel = 'Multiline';
protected static ?string $title = 'Multiline';
public static function form(Schema $schema): Schema public static function form(Schema $schema): Schema
{ {
return MultilineClientForm::configure($schema); return MultilineClientForm::configure($schema);
@@ -41,8 +41,17 @@ class MultilineClientsTable
TextColumn::make('multiline_setting.name')->label('Bettype'), TextColumn::make('multiline_setting.name')->label('Bettype'),
BookmakerIcon::make('bookmaker.icon')->label('Icon'), BookmakerIcon::make('bookmaker.icon')->label('Icon'),
SelectColumn::make('bookmaker_id') SelectColumn::make('bookmaker_id')
->label('Bookmaker')
->width('2rem') ->width('2rem')
->options(Bookmaker::where('is_active', 1)->pluck('name', 'txid')), ->options(function () {
$books = Bookmaker::where('is_active', 1)->orderBy('txid')->pluck('name', 'txid');
foreach ($books as $key => $value) {
$books[$key] = $key.' - '.$value;
}
return $books;
}),
// ->options(Bookmaker::where('is_active', 1)->pluck('name', 'txid')),
]) ])
->defaultSort('sort') ->defaultSort('sort')
->deferFilters(false) ->deferFilters(false)
@@ -0,0 +1,23 @@
<?php
namespace App\Filament\Tables\Columns;
use App\Actions\MultilineSlots;
use Filament\Tables\Columns\Column;
class OddsTotals extends Column
{
protected string $view = 'filament.tables.columns.odds-totals';
protected ?array $slots = [];
public function loadSlots(&$data)
{
$this->slots = MultilineSlots::addSlots($data);
}
public function getSlots(): ?array
{
return $this->slots;
}
}
+5
View File
@@ -54,4 +54,9 @@ class Event extends Model
{ {
return $this->hasMany(Odds3way::class, 'event_id', 'id')->with('bookmaker'); return $this->hasMany(Odds3way::class, 'event_id', 'id')->with('bookmaker');
} }
public function odds_totals()
{
return $this->hasMany(OddsTotal::class, 'event_id', 'id')->with('bookmaker');
}
} }
+1 -1
View File
@@ -18,7 +18,7 @@ class OddsTotal extends Model
'bmoid', 'bmoid',
'over', 'over',
'under', 'under',
'spread', 'total',
'margin', 'margin',
'flag', 'flag',
'nuh_check', 'nuh_check',
@@ -0,0 +1,22 @@
<?php
use App\Utilities\BkmIconMap;
use App\Utilities\OddsFormatting;
?>
<div {{ $getExtraAttributeBag() }} class="grid grid-cols-5 grid-rows-5 oddsbox">
{{ $loadSlots($record->odds_totals) }}
@foreach ($getSlots() as $row)
@if (isset($row->bookmaker))
<div class="bg-contain bg-center bg-no-repeat dark:opacity-90" title="{{ $row->bookmaker->txid }}"
style="background-image: url('{{ BkmIconMap::get($row->bookmaker?->icon) }}')">
</div>
<div class="br bb">{{ OddsFormatting::get($row->over, 2) }}&nbsp;</div>
<div class="br bb">{{ OddsFormatting::get($row->under, 2) }}&nbsp;</div>
<div class="br bb">{{ OddsFormatting::get($row->total, 1) }}&nbsp;</div>
<div class="br bb">{{ OddsFormatting::get($row->margin, 1) }}&nbsp;</div>
@endif
@endforeach
</div>