add color to history

This commit is contained in:
salam committed 2026-03-11 12:15:23 +01:00
1 parent c0b8b7439c
commit 7dea3ce335
4 files changed
+55 -14

No files matched your search

@@ -63,6 +63,8 @@ class EventResource extends Resource
->with('country') ->with('country')
->with('home') ->with('home')
->with('away') ->with('away')
->with('home_betsapi')
->with('away_betsapi')
->with('event_bookmaker') ->with('event_bookmaker')
->with('event_user_star') ->with('event_user_star')
->with('event_user_note') ->with('event_user_note')
+37 -12
View File
@@ -10,6 +10,7 @@ use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Concerns\InteractsWithSchemas; use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas; use Filament\Schemas\Contracts\HasSchemas;
use Filament\Schemas\Schema; use Filament\Schemas\Schema;
use Filament\Support\Enums\FontWeight;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Livewire\Attributes\Lazy; use Livewire\Attributes\Lazy;
@@ -44,16 +45,24 @@ class EncounterHistory extends Component implements HasSchemas
TableColumn::make('Date'), TableColumn::make('Date'),
TableColumn::make('Home'), TableColumn::make('Home'),
TableColumn::make('Away'), TableColumn::make('Away'),
TableColumn::make('Result'), TableColumn::make('Result')->alignCenter(),
]) ])
->schema([ ->schema([
TextEntry::make('league.name'), TextEntry::make('league.name'),
TextEntry::make('time')->formatStateUsing(function ($state) { TextEntry::make('time')->formatStateUsing(function ($state) {
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i'); return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
}), }),
TextEntry::make('home.name'), TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
TextEntry::make('away.name'), $this->home => 'primary',
TextEntry::make('ss'), $this->away => 'success',
default => 'gray',
}),
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
$this->home => 'primary',
$this->away => 'success',
default => 'gray',
}),
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
]), ]),
]), ]),
Tab::make($this->home) Tab::make($this->home)
@@ -65,16 +74,24 @@ class EncounterHistory extends Component implements HasSchemas
TableColumn::make('Date'), TableColumn::make('Date'),
TableColumn::make('Home'), TableColumn::make('Home'),
TableColumn::make('Away'), TableColumn::make('Away'),
TableColumn::make('Result'), TableColumn::make('Result')->alignCenter(),
]) ])
->schema([ ->schema([
TextEntry::make('league.name'), TextEntry::make('league.name'),
TextEntry::make('time')->formatStateUsing(function ($state) { TextEntry::make('time')->formatStateUsing(function ($state) {
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i'); return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
}), }),
TextEntry::make('home.name'), TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
TextEntry::make('away.name'), $this->home => 'primary',
TextEntry::make('ss'), $this->away => 'success',
default => 'gray',
}),
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
$this->home => 'primary',
$this->away => 'success',
default => 'gray',
}),
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
]), ]),
]), ]),
Tab::make($this->away) Tab::make($this->away)
@@ -86,16 +103,24 @@ class EncounterHistory extends Component implements HasSchemas
TableColumn::make('Date'), TableColumn::make('Date'),
TableColumn::make('Home'), TableColumn::make('Home'),
TableColumn::make('Away'), TableColumn::make('Away'),
TableColumn::make('Result'), TableColumn::make('Result')->alignCenter(),
]) ])
->schema([ ->schema([
TextEntry::make('league.name'), TextEntry::make('league.name'),
TextEntry::make('time')->formatStateUsing(function ($state) { TextEntry::make('time')->formatStateUsing(function ($state) {
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i'); return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
}), }),
TextEntry::make('home.name'), TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
TextEntry::make('away.name'), $this->home => 'primary',
TextEntry::make('ss'), $this->away => 'success',
default => 'gray',
}),
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
$this->home => 'primary',
$this->away => 'success',
default => 'gray',
}),
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
]), ]),
]), ]),
]), ]),
+10
View File
@@ -63,6 +63,16 @@ class Event extends Model
return $this->belongsTo(Element::class); return $this->belongsTo(Element::class);
} }
public function home_betsapi()
{
return $this->belongsTo(ElementProvider::class, 'home_id', 'element_id')->where('provider_id', 2);
}
public function away_betsapi()
{
return $this->belongsTo(ElementProvider::class, 'away_id', 'element_id')->where('provider_id', 2);
}
public function odds_2ways() public function odds_2ways()
{ {
return $this->hasMany(Odds2way::class); return $this->hasMany(Odds2way::class);
@@ -38,13 +38,17 @@
</div> </div>
@endif @endif
@if ($record->betsapi_id) @if ($record->betsapi_id && $record->home_betsapi && $record->away_betsapi)
<x-filament::modal width="5xl"> <x-filament::modal width="5xl">
<x-slot name="trigger"> <x-slot name="trigger">
<x-filament::icon-button icon="phosphor-info" color="gray" size="sm" <x-filament::icon-button icon="phosphor-info" color="gray" size="sm"
tooltip="Encounter History" /> tooltip="Encounter History" />
</x-slot> </x-slot>
@livewire('encounter-history', ['betsapi_id' => $record->betsapi_id, 'home' => $record->home->name, 'away' => $record->away->name]) @livewire('encounter-history', [
'betsapi_id' => $record->betsapi_id,
'home' => $record->home_betsapi->name,
'away' => $record->away_betsapi->name,
])
</x-filament::modal> </x-filament::modal>
@endif @endif
</div> </div>