starttime popup

This commit is contained in:
salam committed 2026-02-25 16:27:18 +01:00
1 parent 012747f149
commit 5a44fc18b3
8 files changed
+91 -32

No files matched your search

@@ -68,9 +68,9 @@ class EventResource extends Resource
->where('sport_id', auth()->user()->sport_id);
if (config('env.app_env') == 'production') {
$query->whereDate('starttime', '>=', Carbon::now()->subHour());
$query->where('starttime', '>=', Carbon::now()->subHour());
} else {
$query->whereDate('starttime', '>=', Carbon::now());
$query->where('starttime', '>=', Carbon::now());
}
if (auth()->user()->all_only_none > 0) {
@@ -7,6 +7,7 @@ use App\Filament\Resources\Events\Tables\Tools\LoadBettypeSettings;
use App\Filament\Resources\Events\Tables\Tools\LoadCompareDifferences;
use App\Filament\Resources\Events\Tables\Tools\LoadMultiline;
use App\Filament\Tables\Columns\ColumnOdds;
use App\Filament\Tables\Columns\ColumnStarttime;
use App\Filament\Tables\Columns\EventColumn;
use App\Filament\Tables\Columns\MatchIds;
use App\Filament\Tables\Columns\TooltipOdds;
@@ -29,7 +30,6 @@ use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\FusedGroup;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\VerticalAlignment;
use Filament\Support\Enums\Width;
use Filament\Tables\Columns\IconColumn;
@@ -76,26 +76,7 @@ class EventsTable
MatchIds::make('ids')->grow(false)->visibleFrom('xl')
->visible(fn () => auth()->user()->hasRole('super_admin')),
TextColumn::make('event_bookmaker.starttime')
->timezone('CET')
->label('Start')
->alignCenter()
->dateTime('H:i')
->weight(FontWeight::Bold)
->color(function ($record) {
$bkm = $record->event_bookmaker?->starttime ?? null;
if ($bkm) {
return $bkm != $record->starttime ? 'danger' : 'info';
}
return 'gray';
})
->state(function ($record) {
return $record->event_bookmaker->starttime ?? $record->starttime;
})
->description(fn ($record): string => Carbon::createFromDate($record->event_bookmaker->starttime ?? $record->starttime)->format('d. M')),
ColumnStarttime::make('start'),
TextColumn::make('country.name')
->wrap()
->hidden(fn () => auth()->user()->sport_id == 5)
@@ -0,0 +1,72 @@
<?php
namespace App\Filament\Tables\Columns;
use App\Models\EventBookmaker;
use Filament\Support\Components\Contracts\HasEmbeddedView;
use Filament\Tables\Columns\Column;
use Illuminate\Support\Carbon;
class ColumnStarttime extends Column implements HasEmbeddedView
{
public function toEmbeddedHtml(): string
{
$record = $this->getRecord();
$bookmaker_starttimes = EventBookmaker::with('bookmaker')->where('event_id', $record->id)->select('bookmaker_id', 'starttime')->get();
$pop = '<div class="grid grid-cols-2 gap-1">';
$pop .= '<div>TxOdds</div>';
$pop .= '<div>'.$record->starttime.'</div>';
foreach ($bookmaker_starttimes as $value) {
$pop .= '<div>'.$value->bookmaker->name.'</div>';
$pop .= '<div>'.$value->starttime.'</div>';
}
$pop .= '<div>';
$client_starttime = $record->event_bookmaker->starttime ?? null;
$txodds_starttime = $record->starttime ?? null;
if ($client_starttime) {
if ($client_starttime == $txodds_starttime) {
$color = 'fi-color fi-color-success fi-text-color-600 dark:fi-text-color-400 fi-ta-text-item';
} else {
$color = 'fi-color fi-color-warning fi-text-color-600 dark:fi-text-color-400 fi-ta-text-item';
}
$starttime = Carbon::createFromTimestamp(strtotime($client_starttime))->timezone('CET');
} else {
$color = 'fi-color fi-color-info fi-text-color-600 dark:fi-text-color-400 fi-ta-text-item';
$starttime = Carbon::createFromTimestamp(strtotime($txodds_starttime))->timezone('CET');
}
ob_start(); ?>
<div x-data="{ pop: '<?= e($pop) ?>' }" class="my-auto flex flex-col gap-4 cursor-pointer">
<template x-ref="template">
<p x-html="pop"></p>
</template>
<div class="mx-auto grid grid-cols-1 gap-0 justify-center"
x-tooltip.html="{ content: () =>
$refs.template.innerHTML,
placement: 'auto',
allowHTML: true,
theme: $store.theme,
class: 'tooltip',
appendTo: $root,
strategy: 'fixed',
interactive: false,
zIndex: 99999,
popperOptions: {
strategy: 'fixed',
},
}">
<div class="text-center <?= e($color) ?>">
<?= e($starttime->format('H:i')) ?>
</div>
<div class="text-center fi-color fi-color-gray fi-text-color-500 dark:fi-text-color-400 fi-size-xs fi-ta-text-item">
<?= e($starttime->format('d. M')) ?>
</div>
</div>
</div>
<?php return ob_get_clean();
}
}