toggle bettypes
This commit is contained in:
1 parent
21575d799f
commit
739222718a
15 files changed
+132
-78
No files matched your search
@@ -10,6 +10,8 @@ class ListEvents extends ListRecords
|
|||||||
{
|
{
|
||||||
protected static string $resource = EventResource::class;
|
protected static string $resource = EventResource::class;
|
||||||
|
|
||||||
|
protected $listeners = ['refreshBettypeMenu' => '$refresh'];
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Events\Tables;
|
namespace App\Filament\Resources\Events\Tables;
|
||||||
|
|
||||||
use App\Filament\Tables\Columns\Columns3way;
|
use App\Filament\Tables\Columns\Column3way;
|
||||||
|
use App\Filament\Tables\Columns\ColumnDc;
|
||||||
use App\Filament\Tables\Columns\MatchIds;
|
use App\Filament\Tables\Columns\MatchIds;
|
||||||
use App\Models\BettypeUser;
|
use App\Models\BettypeUser;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
@@ -68,7 +69,8 @@ class EventsTable
|
|||||||
->alignRight(),
|
->alignRight(),
|
||||||
TextColumn::make('away.name')
|
TextColumn::make('away.name')
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Columns3way::make('odds3way')->label(fn () => view('filament.tables.columns.multiline.labels')),
|
Column3way::make('odds3way')->visible(fn () => in_array(1, self::$bettype_settings))->width(280)->label(fn () => view('filament.tables.columns.multiline.labels', ['menu' => '1x2'])),
|
||||||
|
ColumnDc::make('oddsdc')->visible(fn () => in_array(2, self::$bettype_settings))->width(280)->label(fn () => view('filament.tables.columns.multiline.labels', ['menu' => 'dc'])),
|
||||||
])
|
])
|
||||||
->poll('10s')
|
->poll('10s')
|
||||||
->defaultSort('starttime', 'ASC')
|
->defaultSort('starttime', 'ASC')
|
||||||
|
|||||||
+2
-2
@@ -5,9 +5,9 @@ namespace App\Filament\Tables\Columns;
|
|||||||
use App\Models\Odds3way;
|
use App\Models\Odds3way;
|
||||||
use Filament\Tables\Columns\Column;
|
use Filament\Tables\Columns\Column;
|
||||||
|
|
||||||
class Columns3way extends Column
|
class Column3way extends Column
|
||||||
{
|
{
|
||||||
protected string $view = 'filament.tables.columns.columns_3way';
|
protected string $view = 'filament.tables.columns.column_3way';
|
||||||
|
|
||||||
protected ?array $multiline;
|
protected ?array $multiline;
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Tables\Columns;
|
||||||
|
|
||||||
|
use App\Models\OddsDc;
|
||||||
|
use Filament\Tables\Columns\Column;
|
||||||
|
|
||||||
|
class ColumnDc extends Column
|
||||||
|
{
|
||||||
|
protected string $view = 'filament.tables.columns.column-dc';
|
||||||
|
|
||||||
|
protected ?array $multiline;
|
||||||
|
|
||||||
|
protected ?array $fumetto;
|
||||||
|
|
||||||
|
protected ?bool $has_odds;
|
||||||
|
|
||||||
|
public function loadData($record, $multiline_client)
|
||||||
|
{
|
||||||
|
|
||||||
|
$res = OddsDc::with('bookmaker')->where('event_id', $record->id)->get();
|
||||||
|
|
||||||
|
$this->fumetto = [];
|
||||||
|
|
||||||
|
$this->multiline = [];
|
||||||
|
|
||||||
|
foreach ($res as $item) {
|
||||||
|
|
||||||
|
$this->fumetto[] = $item;
|
||||||
|
foreach ($multiline_client as $slot => $bookmaker) {
|
||||||
|
if ($item->bookmaker_id == $bookmaker->bookmaker_id) {
|
||||||
|
$this->multiline[$slot] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->has_odds = count($this->multiline) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMultilines(): ?array
|
||||||
|
{
|
||||||
|
return $this->multiline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFumetto()
|
||||||
|
{
|
||||||
|
return $this->fumetto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasodds()
|
||||||
|
{
|
||||||
|
return $this->has_odds;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,30 +2,30 @@
|
|||||||
|
|
||||||
namespace App\Livewire;
|
namespace App\Livewire;
|
||||||
|
|
||||||
use App\Models\MultilineSetting;
|
use App\Models\BettypeUser;
|
||||||
use App\Models\User;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class BettypeToggle extends Component
|
class BettypeToggle extends Component
|
||||||
{
|
{
|
||||||
public $multilines = [];
|
public $multilines = [];
|
||||||
|
|
||||||
public function mount()
|
protected $listeners = [
|
||||||
{
|
'refreshBettypeMenu' => '$refresh',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
$this->multilines = [];
|
$this->multilines = [];
|
||||||
|
|
||||||
$settings = MultilineSetting::where('sport_id', auth()->user()->sport_id)->get();
|
$res = BettypeUser::with('multiline')->where('user_id', auth()->user()->id)->where('sport_id', auth()->user()->sport_id)->get();
|
||||||
|
|
||||||
foreach ($settings as $setting) {
|
|
||||||
|
|
||||||
|
foreach ($res as $set) {
|
||||||
$this->multilines[] = [
|
$this->multilines[] = [
|
||||||
'id' => $setting->id,
|
'id' => $set->multiline_setting_id,
|
||||||
'sport_id' => $setting->sport_id,
|
'name' => $set->multiline->name,
|
||||||
'name' => $setting->name,
|
'short' => $set->multiline->short,
|
||||||
'short' => $setting->short,
|
'is_active' => $set->is_active,
|
||||||
'table' => $setting->table,
|
|
||||||
'is_active' => $setting->id == auth()->user()->multiline_setting_id ? 1 : 0,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,17 +35,10 @@ class BettypeToggle extends Component
|
|||||||
return view('livewire.bettype-toggle');
|
return view('livewire.bettype-toggle');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function swopBettype($multiline_setting_id)
|
public function toggleBettype($multiline_setting_id)
|
||||||
{
|
{
|
||||||
User::where('id', auth()->user()->id)->update(['multiline_setting_id' => $multiline_setting_id]);
|
BettypeUser::where('user_id', auth()->user()->id)->where('multiline_setting_id', $multiline_setting_id)->update(['is_active' => DB::raw('!is_active')]);
|
||||||
|
|
||||||
$this->js('window.location.reload()');
|
$this->dispatch('refreshBettypeMenu');
|
||||||
}
|
|
||||||
|
|
||||||
public function toggleBettype($sport, $bettype, $status)
|
|
||||||
{
|
|
||||||
User::where('id', auth()->user()->id)->update(["bettype_status->$sport->$bettype" => $status]);
|
|
||||||
|
|
||||||
$this->js('window.location.reload()');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,4 +12,9 @@ class BettypeUser extends Model
|
|||||||
'multiline_setting_id',
|
'multiline_setting_id',
|
||||||
'is_active',
|
'is_active',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function multiline()
|
||||||
|
{
|
||||||
|
return $this->hasOne(MultilineSetting::class, 'id', 'multiline_setting_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Generated
+10
-10
@@ -10854,35 +10854,35 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "11.0.11",
|
"version": "11.0.12",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4"
|
"reference": "2c1ed04922802c15e1de5d7447b4856de949cf56"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2c1ed04922802c15e1de5d7447b4856de949cf56",
|
||||||
"reference": "4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4",
|
"reference": "2c1ed04922802c15e1de5d7447b4856de949cf56",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"ext-libxml": "*",
|
"ext-libxml": "*",
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"nikic/php-parser": "^5.4.0",
|
"nikic/php-parser": "^5.7.0",
|
||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
"phpunit/php-file-iterator": "^5.1.0",
|
"phpunit/php-file-iterator": "^5.1.0",
|
||||||
"phpunit/php-text-template": "^4.0.1",
|
"phpunit/php-text-template": "^4.0.1",
|
||||||
"sebastian/code-unit-reverse-lookup": "^4.0.1",
|
"sebastian/code-unit-reverse-lookup": "^4.0.1",
|
||||||
"sebastian/complexity": "^4.0.1",
|
"sebastian/complexity": "^4.0.1",
|
||||||
"sebastian/environment": "^7.2.0",
|
"sebastian/environment": "^7.2.1",
|
||||||
"sebastian/lines-of-code": "^3.0.1",
|
"sebastian/lines-of-code": "^3.0.1",
|
||||||
"sebastian/version": "^5.0.2",
|
"sebastian/version": "^5.0.2",
|
||||||
"theseer/tokenizer": "^1.2.3"
|
"theseer/tokenizer": "^1.3.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^11.5.2"
|
"phpunit/phpunit": "^11.5.46"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-pcov": "PHP extension that provides line coverage",
|
"ext-pcov": "PHP extension that provides line coverage",
|
||||||
@@ -10920,7 +10920,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
|
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.11"
|
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.12"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -10940,7 +10940,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-08-27T14:37:49+00:00"
|
"time": "2025-12-24T07:01:01+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
|
|||||||
Generated
-2
@@ -1990,7 +1990,6 @@
|
|||||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
@@ -2224,7 +2223,6 @@
|
|||||||
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
|
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.27.0",
|
"esbuild": "^0.27.0",
|
||||||
"fdir": "^6.5.0",
|
"fdir": "^6.5.0",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ button[wire\:click="resetTableFiltersForm"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.fi-ta-header-cell-odds3way,
|
.fi-ta-header-cell-odds3way,
|
||||||
|
.fi-ta-header-cell-oddsdc,
|
||||||
.fi-ta-header-cell-id {
|
.fi-ta-header-cell-id {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
@php
|
||||||
|
$loadData($record, $record->multiline_client);
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@include('filament.tables.columns.multiline.fumetto')
|
||||||
|
|
||||||
|
<div {{ $getExtraAttributeBag() }}
|
||||||
|
class="max-w-80 grid grid-cols-5 grid-rows-4 text-xs gap-0 justify-between text-right">
|
||||||
|
|
||||||
|
@foreach ($getMultilines() as $item)
|
||||||
|
@include('filament.tables.columns.multiline.bkm', [
|
||||||
|
'bookmaker_id' => $item->bookmaker_id,
|
||||||
|
'icon' => $item->bookmaker->icon ?? '',
|
||||||
|
])
|
||||||
|
|
||||||
|
@include('filament.tables.columns.multiline.odds', ['odd' => $item->dc1x, 'decimal' => 2])
|
||||||
|
|
||||||
|
@include('filament.tables.columns.multiline.odds', ['odd' => $item->dc12, 'decimal' => 2])
|
||||||
|
|
||||||
|
@include('filament.tables.columns.multiline.odds', ['odd' => $item->dc2x, 'decimal' => 2])
|
||||||
|
|
||||||
|
@include('filament.tables.columns.multiline.odds', ['odd' => $item->margin, 'decimal' => 1])
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
+3
-2
@@ -4,12 +4,13 @@
|
|||||||
|
|
||||||
@include('filament.tables.columns.multiline.fumetto')
|
@include('filament.tables.columns.multiline.fumetto')
|
||||||
|
|
||||||
<div {{ $getExtraAttributeBag() }} class="max-w-80 grid grid-cols-5 grid-rows-4 text-xs gap-0 justify-between">
|
<div {{ $getExtraAttributeBag() }}
|
||||||
|
class="max-w-80 grid grid-cols-5 grid-rows-4 text-xs gap-0 justify-between text-right">
|
||||||
|
|
||||||
@foreach ($getMultilines() as $item)
|
@foreach ($getMultilines() as $item)
|
||||||
@include('filament.tables.columns.multiline.bkm', [
|
@include('filament.tables.columns.multiline.bkm', [
|
||||||
'bookmaker_id' => $item->bookmaker_id,
|
'bookmaker_id' => $item->bookmaker_id,
|
||||||
'icon' => $item->bookmaker->icon,
|
'icon' => $item->bookmaker->icon ?? '',
|
||||||
])
|
])
|
||||||
|
|
||||||
@include('filament.tables.columns.multiline.odds', ['odd' => $item->h3w, 'decimal' => 2])
|
@include('filament.tables.columns.multiline.odds', ['odd' => $item->h3w, 'decimal' => 2])
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
@foreach ($getFumetto() as $item)
|
@foreach ($getFumetto() as $item)
|
||||||
@include('filament.tables.columns.multiline.bkm', [
|
@include('filament.tables.columns.multiline.bkm', [
|
||||||
'bookmaker_id' => $item->bookmaker_id,
|
'bookmaker_id' => $item->bookmaker_id,
|
||||||
'icon' => $item->bookmaker->icon,
|
'icon' => $item->bookmaker->icon ?? '',
|
||||||
])
|
])
|
||||||
|
|
||||||
@include('filament.tables.columns.multiline.odds', [
|
@include('filament.tables.columns.multiline.odds', [
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
@switch(auth()->user()->multiline_setting_id)
|
@switch($menu)
|
||||||
@case(1)
|
@case('1x2')
|
||||||
@case(13)
|
|
||||||
<div class="grid grid-cols-6 grid-rows-1 text-xs gap-0 justify-between text-center">
|
<div class="grid grid-cols-6 grid-rows-1 text-xs gap-0 justify-between text-center">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
@@ -11,17 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@break
|
@break
|
||||||
|
|
||||||
@case(7)
|
@case('hc')
|
||||||
@case(12)
|
|
||||||
|
|
||||||
@case(16)
|
|
||||||
@case(17)
|
|
||||||
|
|
||||||
@case(8)
|
|
||||||
@case(14)
|
|
||||||
|
|
||||||
@case(9)
|
|
||||||
@case(5)
|
|
||||||
<div class="grid grid-cols-5 grid-rows-1 text-xs gap-0 justify-between text-center">
|
<div class="grid grid-cols-5 grid-rows-1 text-xs gap-0 justify-between text-center">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
@@ -31,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@break
|
@break
|
||||||
|
|
||||||
@case(2)
|
@case('dc')
|
||||||
<div class="grid grid-cols-6 grid-rows-1 text-xs gap-0 justify-between text-center">
|
<div class="grid grid-cols-6 grid-rows-1 text-xs gap-0 justify-between text-center">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
@@ -42,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@break
|
@break
|
||||||
|
|
||||||
@case(3)
|
@case('dnb')
|
||||||
<div class="grid grid-cols-5 grid-rows-1 text-xs gap-0 justify-between text-center">
|
<div class="grid grid-cols-5 grid-rows-1 text-xs gap-0 justify-between text-center">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
@@ -52,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@break
|
@break
|
||||||
|
|
||||||
@case(4)
|
@case('gg')
|
||||||
<div class="grid grid-cols-5 grid-rows-1 text-xs gap-0 justify-between text-center">
|
<div class="grid grid-cols-5 grid-rows-1 text-xs gap-0 justify-between text-center">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
@@ -62,13 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@break
|
@break
|
||||||
|
|
||||||
@case(6)
|
@case('ou')
|
||||||
@case(10)
|
|
||||||
|
|
||||||
@case(15)
|
|
||||||
@case(18)
|
|
||||||
|
|
||||||
@case(11)
|
|
||||||
<div class="grid grid-cols-6 grid-rows-1 text-xs gap-0 justify-between text-center">
|
<div class="grid grid-cols-6 grid-rows-1 text-xs gap-0 justify-between text-center">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use App\Utilities\OddsFormatting;
|
use App\Utilities\OddsFormatting;
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<div class="h-4 text-right mb-0.5 ml-0.5 border border-white">
|
<div class="h-4 mb-0.5 ml-0.5 border border-white">
|
||||||
|
|
||||||
@if (isset($odd))
|
@if (isset($odd))
|
||||||
{{ OddsFormatting::get($odd, $decimal) }}
|
{{ OddsFormatting::get($odd, $decimal) }}
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
<div class="flex gap-4 justify-end">
|
<div class="flex gap-4 justify-end">
|
||||||
|
|
||||||
@foreach ($multilines as $multiline)
|
@foreach ($multilines as $multiline)
|
||||||
@if ($multiline['is_active'] == 1)
|
<x-filament::button tooltip="{{ $multiline['name'] }}" wire:click="toggleBettype({{ $multiline['id'] }})"
|
||||||
<x-filament::button>
|
wire:dispatch="refreshTable" :color="!$multiline['is_active'] ? 'gray' : 'primary'"> {{ $multiline['short'] }} </x-filament::button>
|
||||||
{{ $multiline['short'] }}
|
|
||||||
</x-filament::button>
|
|
||||||
@else
|
|
||||||
<x-filament::button outlined color="gray" tooltip="{{ $multiline['name'] }}"
|
|
||||||
wire:click="swopBettype({{ $multiline['id'] }})">
|
|
||||||
{{ $multiline['short'] }}
|
|
||||||
</x-filament::button>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user