EncounterHistory
This commit is contained in:
1 parent
d08613c54c
commit
f3b59268b0
6 files changed
+138
-86
No files matched your search
@@ -0,0 +1,117 @@
|
||||
<?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 Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Component;
|
||||
|
||||
class EncounterHistory extends Component implements HasSchemas
|
||||
{
|
||||
use InteractsWithSchemas;
|
||||
|
||||
public $data = [];
|
||||
|
||||
public $home;
|
||||
|
||||
public $away;
|
||||
|
||||
public function eventsInfolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->record($this->data)
|
||||
->components([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make($this->home.' vs '.$this->away)
|
||||
->schema([
|
||||
RepeatableEntry::make('results.h2h')
|
||||
->label('Direct ecounters')
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result'),
|
||||
])
|
||||
->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 ($state) => $state == $this->home ? 'primary' : 'warning'),
|
||||
TextEntry::make('away.name')->color(fn ($state) => $state == $this->away ? 'warning' : 'primary'),
|
||||
TextEntry::make('ss'),
|
||||
]),
|
||||
]),
|
||||
Tab::make($this->home)
|
||||
->schema([
|
||||
RepeatableEntry::make('results.home')
|
||||
->label($this->home)
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result'),
|
||||
])
|
||||
->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 ($state) => $state == $this->home ? 'primary' : 'gray'),
|
||||
TextEntry::make('away.name')->color(fn ($state) => $state == $this->home ? 'primary' : 'gray'),
|
||||
TextEntry::make('ss'),
|
||||
]),
|
||||
]),
|
||||
Tab::make($this->away)
|
||||
->schema([
|
||||
RepeatableEntry::make('results.away')
|
||||
->label($this->away)
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result'),
|
||||
])
|
||||
->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 ($state) => $state == $this->away ? 'warning' : 'gray'),
|
||||
TextEntry::make('away.name')->color(fn ($state) => $state == $this->away ? 'warning' : 'gray'),
|
||||
TextEntry::make('ss'),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function mount($betsapi_id)
|
||||
{
|
||||
$this->data = Http::get('https://api.b365api.com/v1/event/history?token='.config('env.betsapi_token').'&event_id='.$betsapi_id)->json();
|
||||
$this->home = $this->data['results']['h2h']['0']['home']['name'];
|
||||
$this->away = $this->data['results']['h2h']['0']['away']['name'];
|
||||
}
|
||||
|
||||
public function getHome()
|
||||
{
|
||||
return $this->home;
|
||||
}
|
||||
|
||||
public function getAway()
|
||||
{
|
||||
return $this->away;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Infolists\Components\RepeatableEntry;
|
||||
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 Illuminate\Support\Facades\Http;
|
||||
use Livewire\Component;
|
||||
|
||||
class EncounterHistroy extends Component implements HasActions, HasSchemas
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
|
||||
public $record;
|
||||
|
||||
public $history;
|
||||
|
||||
public function mount($record)
|
||||
{
|
||||
// $this->record = $record;
|
||||
|
||||
$this->record = Http::get('https://api.b365api.com/v1/event/history?token='.config('env.betsapi_token').'&event_id='.$record->betsapi_id)->json();
|
||||
}
|
||||
|
||||
public function eventInfolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->record($this->record)
|
||||
->components([
|
||||
RepeatableEntry::make('comments')
|
||||
->schema([
|
||||
TextEntry::make('results'),
|
||||
])
|
||||
->columns(2),
|
||||
// Tabs::make('Tabs')
|
||||
// ->tabs([
|
||||
// Tab::make($this->record->home->name.' vs '.$this->record->away->name)
|
||||
// ->schema([
|
||||
// TextEntry::make('home.name'),
|
||||
// ]),
|
||||
// Tab::make($this->record->home->name)
|
||||
// ->schema([
|
||||
// TextEntry::make($this->history->result->h2h->name),
|
||||
// ]),
|
||||
// Tab::make($this->record->away->name)
|
||||
// ->schema([
|
||||
// // ...
|
||||
// ]),
|
||||
// ])->vertical(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.encounter-histroy');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user