EncounterHistory

This commit is contained in:
salam committed 2026-03-09 11:44:35 +01:00
1 parent d08613c54c
commit f3b59268b0
6 files changed
+138 -86

No files matched your search

+117
View File
@@ -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;
}
}
-65
View File
@@ -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');
}
}
Generated
+9 -9
View File
@@ -9607,16 +9607,16 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "barryvdh/laravel-debugbar", "name": "barryvdh/laravel-debugbar",
"version": "v4.1.0", "version": "v4.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/fruitcake/laravel-debugbar.git", "url": "https://github.com/fruitcake/laravel-debugbar.git",
"reference": "5cbe5fc76054723ab9501917b7d252cdafb5ad5d" "reference": "048876cf8ffdd8af2b82306289e2c0453fa0b059"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/fruitcake/laravel-debugbar/zipball/5cbe5fc76054723ab9501917b7d252cdafb5ad5d", "url": "https://api.github.com/repos/fruitcake/laravel-debugbar/zipball/048876cf8ffdd8af2b82306289e2c0453fa0b059",
"reference": "5cbe5fc76054723ab9501917b7d252cdafb5ad5d", "reference": "048876cf8ffdd8af2b82306289e2c0453fa0b059",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -9690,7 +9690,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/fruitcake/laravel-debugbar/issues", "issues": "https://github.com/fruitcake/laravel-debugbar/issues",
"source": "https://github.com/fruitcake/laravel-debugbar/tree/v4.1.0" "source": "https://github.com/fruitcake/laravel-debugbar/tree/v4.1.1"
}, },
"funding": [ "funding": [
{ {
@@ -9702,7 +9702,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2026-03-07T19:01:10+00:00" "time": "2026-03-08T08:20:19+00:00"
}, },
{ {
"name": "brianium/paratest", "name": "brianium/paratest",
@@ -13404,12 +13404,12 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": {}, "stability-flags": [],
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": "^8.3" "php": "^8.3"
}, },
"platform-dev": {}, "platform-dev": [],
"plugin-api-version": "2.9.0" "plugin-api-version": "2.6.0"
} }
@@ -14,7 +14,6 @@
@endif @endif
<div>{{ $record->home?->name }}</div> <div>{{ $record->home?->name }}</div>
</div> </div>
{{-- <div class="text-gray-600 dark:!text-gray-400 text-xs">{{ $record->group?->name }}</div> --}}
</div> </div>
@else @else
<div {{ $getExtraAttributeBag() }} class="w-full"> <div {{ $getExtraAttributeBag() }} class="w-full">
@@ -34,15 +33,16 @@
{{ $record->away?->name }} {{ $record->away?->name }}
</div> </div>
</div> </div>
{{-- <div class="text-gray-600 dark:!text-gray-400 text-xs">{{ $record->group?->name }}</div> --}}
</div> </div>
@endif @endif
<x-filament::modal width="5xl"> @if ($record->betsapi_id)
<x-slot name="trigger"> <x-filament::modal width="5xl">
<x-filament::icon-button icon="phosphor-info" color="gray" size="sm" tooltip="Encounter History" /> <x-slot name="trigger">
</x-slot> <x-filament::icon-button icon="phosphor-info" color="gray" size="sm"
tooltip="Encounter History" />
@livewire('encounter-histroy', ['record' => $record]) </x-slot>
</x-filament::modal> @livewire('encounter-history', ['betsapi_id' => $record->betsapi_id])
</x-filament::modal>
@endif
</div> </div>
@@ -0,0 +1,3 @@
<div>
{{ $this->eventsInfolist }}
</div>
@@ -1,3 +0,0 @@
<div>
{{ $this->eventInfolist }}
</div>