wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Filament\Infolists\Components\RepeatableEntry;
|
||||
use Filament\Infolists\Components\RepeatableEntry\TableColumn;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Attributes\Lazy;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Lazy]
|
||||
class EncounterHistory extends Component implements HasSchemas
|
||||
{
|
||||
use InteractsWithSchemas;
|
||||
|
||||
public $data = [];
|
||||
|
||||
public $betsapi_id;
|
||||
|
||||
public $home;
|
||||
|
||||
public $away;
|
||||
|
||||
public function eventsInfolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->record($this->getData())
|
||||
->components([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make($this->home.' vs '.$this->away)
|
||||
->badge(fn ($record) => count($record['results']['h2h']))
|
||||
->schema([
|
||||
RepeatableEntry::make('results.h2h')
|
||||
->hiddenLabel()
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result')->alignCenter(),
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('league.name'),
|
||||
TextEntry::make('time')->formatStateUsing(function ($state) {
|
||||
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
|
||||
}),
|
||||
TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
|
||||
]),
|
||||
]),
|
||||
Tab::make($this->home)
|
||||
->badge(fn ($record) => count($record['results']['home']))
|
||||
->schema([
|
||||
RepeatableEntry::make('results.home')
|
||||
->hiddenLabel()
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result')->alignCenter(),
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('league.name'),
|
||||
TextEntry::make('time')->formatStateUsing(function ($state) {
|
||||
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
|
||||
}),
|
||||
TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
|
||||
]),
|
||||
]),
|
||||
Tab::make($this->away)
|
||||
->badge(fn ($record) => count($record['results']['away']))
|
||||
->schema([
|
||||
RepeatableEntry::make('results.away')
|
||||
->hiddenLabel()
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result')->alignCenter(),
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('league.name'),
|
||||
TextEntry::make('time')->formatStateUsing(function ($state) {
|
||||
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
|
||||
}),
|
||||
TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
|
||||
]),
|
||||
]),
|
||||
])->contained(false),
|
||||
]);
|
||||
}
|
||||
|
||||
public function mount($betsapi_id, $home, $away)
|
||||
{
|
||||
$this->betsapi_id = $betsapi_id;
|
||||
$this->home = $home;
|
||||
$this->away = $away;
|
||||
}
|
||||
|
||||
public function getHome()
|
||||
{
|
||||
return $this->home;
|
||||
}
|
||||
|
||||
public function getAway()
|
||||
{
|
||||
return $this->away;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return Http::get('https://api.b365api.com/v1/event/history?token='.config('env.betsapi_token').'&event_id='.$this->betsapi_id)->json();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user