73 lines
2.9 KiB
PHP
73 lines
2.9 KiB
PHP
<?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();
|
|
}
|
|
}
|