From 79271f22e152470880bf320b2fb3b370023dae2a Mon Sep 17 00:00:00 2001 From: salam Date: Wed, 25 Feb 2026 17:03:05 +0100 Subject: [PATCH] popup time order by bookmaker name --- app/Console/Commands/Grapper/TxOdds/Odds.php | 46 +++++++++---------- .../Tables/Columns/ColumnStarttime.php | 13 ++++-- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/Console/Commands/Grapper/TxOdds/Odds.php b/app/Console/Commands/Grapper/TxOdds/Odds.php index 84dda2e6..31dc518c 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds.php @@ -317,16 +317,14 @@ class Odds case 0: foreach ($offer->odds->attributes() as $attributeName => $attributeValue) { switch ($attributeName) { - case 'starting_time': - $res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first(); - if ($res && $res->starttime != $attributeValue) { - $res->starttime = $attributeValue; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); - - } + DB::transaction(function () use ($odds, $sport_id, $event_id, $bookmaker_id, $attributeValue) { + EventBookmaker::updateOrCreate([ + 'event_id' => $event_id, + 'sport_id' => $sport_id, + 'bookmaker_id' => $bookmaker_id, + ], ['in_feed' => 1, 'bmoid' => $odds['bmoid'], 'starttime' => $attributeValue]); + }, 5); break; } } @@ -337,14 +335,13 @@ class Odds foreach ($offer->odds->attributes() as $attributeName => $attributeValue) { switch ($attributeName) { case 'starting_time': - - $res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first(); - if ($res && $res->starttime != $attributeValue) { - $res->starttime = $attributeValue; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); - } + DB::transaction(function () use ($odds, $sport_id, $event_id, $bookmaker_id, $attributeValue) { + EventBookmaker::updateOrCreate([ + 'event_id' => $event_id, + 'sport_id' => $sport_id, + 'bookmaker_id' => $bookmaker_id, + ], ['in_feed' => 1, 'bmoid' => $odds['bmoid'], 'starttime' => $attributeValue]); + }, 5); break; } } @@ -356,14 +353,13 @@ class Odds foreach ($offer->odds->attributes() as $attributeName => $attributeValue) { switch ($attributeName) { case 'starting_time': - - $res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first(); - if ($res && $res->starttime != $attributeValue) { - $res->starttime = $attributeValue; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); - } + DB::transaction(function () use ($odds, $sport_id, $event_id, $bookmaker_id, $attributeValue) { + EventBookmaker::updateOrCreate([ + 'event_id' => $event_id, + 'sport_id' => $sport_id, + 'bookmaker_id' => $bookmaker_id, + ], ['in_feed' => 1, 'bmoid' => $odds['bmoid'], 'starttime' => $attributeValue]); + }, 5); break; } } diff --git a/app/Filament/Tables/Columns/ColumnStarttime.php b/app/Filament/Tables/Columns/ColumnStarttime.php index 1313d5dc..7e585dc7 100644 --- a/app/Filament/Tables/Columns/ColumnStarttime.php +++ b/app/Filament/Tables/Columns/ColumnStarttime.php @@ -6,6 +6,7 @@ use App\Models\EventBookmaker; use Filament\Support\Components\Contracts\HasEmbeddedView; use Filament\Tables\Columns\Column; use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\DB; class ColumnStarttime extends Column implements HasEmbeddedView { @@ -13,14 +14,18 @@ class ColumnStarttime extends Column implements HasEmbeddedView { $record = $this->getRecord(); - $bookmaker_starttimes = EventBookmaker::with('bookmaker')->where('event_id', $record->id)->select('bookmaker_id', 'starttime')->get(); + $bookmaker_starttimes = EventBookmaker::where('event_id', $record->id) + ->join('bookmakers', 'bookmakers.id', '=', 'event_bookmakers.bookmaker_id') + ->select('bookmaker_id', DB::raw('TIME(starttime) AS starttime')) + ->orderBy('bookmakers.name') + ->get(); - $pop = '
'; + $pop = '
'; $pop .= '
TxOdds
'; - $pop .= '
'.$record->starttime.'
'; + $pop .= '
'.date('H:i:s', strtotime($record->starttime)).'
'; foreach ($bookmaker_starttimes as $value) { $pop .= '
'.$value->bookmaker->name.'
'; - $pop .= '
'.$value->starttime.'
'; + $pop .= '
'.$value->starttime.'
'; } $pop .= '
';