multilines wip

This commit is contained in:
salam committed 2025-12-13 09:57:15 +01:00
1 parent 218c1e6e1c
commit 825a8d430c
19 files changed
+145 -78

No files matched your search

-8
View File
@@ -1,8 +0,0 @@
<?php
namespace App\Actions;
class MultilineGenerator
{
public static function run() {}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Actions;
use App\Models\Multiline;
class MultilineSlots
{
public static function addSlots(&$data, $bettype_id, $matchpart_id)
{
$slots = Multiline::where('sport_id', auth()->user()->sport_id)
->where('client_id', auth()->user()->client_id)
->where('bettype_id', $bettype_id)
->where('matchpart_id', $matchpart_id)
->with('bookmaker')
->orderBy('sort')
->get();
$multilines = [];
foreach ($slots as $id => $slot) {
$open = true;
foreach ($data as $item) {
if ($slot->bookmaker_id == $item->bookmaker_id) {
$multilines[$id] = $item;
$open = false;
}
}
if ($open) {
$multilines[$id] = $slot;
}
}
return $multilines;
}
}
@@ -6,7 +6,6 @@ use App\Filament\Resources\Events\Pages\ListEvents;
use App\Filament\Resources\Events\Schemas\EventForm; use App\Filament\Resources\Events\Schemas\EventForm;
use App\Filament\Resources\Events\Tables\EventsTable; use App\Filament\Resources\Events\Tables\EventsTable;
use App\Models\Event; use App\Models\Event;
use App\Models\Multiline;
use Carbon\Carbon; use Carbon\Carbon;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Schemas\Schema; use Filament\Schemas\Schema;
@@ -27,11 +26,6 @@ class EventResource extends Resource
protected static ?string $pluralModelLabel = 'Monitor'; protected static ?string $pluralModelLabel = 'Monitor';
public static function getPluralModelLabel(): string
{
return '';
}
public static function form(Schema $schema): Schema public static function form(Schema $schema): Schema
{ {
return EventForm::configure($schema); return EventForm::configure($schema);
@@ -42,13 +36,6 @@ class EventResource extends Resource
return EventsTable::configure($table); return EventsTable::configure($table);
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array public static function getPages(): array
{ {
return [ return [
@@ -66,15 +53,7 @@ class EventResource extends Resource
public static function getEloquentQuery(): Builder public static function getEloquentQuery(): Builder
{ {
// $_bookmaker = Multiline::where('sport_id', auth()->user()->sport_id)
// ->where('client_id', auth()->user()->client_id)
// ->where('bettype_id', 1)
// ->where('matchpart_id', 1)
// ->pluck('bookmaker_id')
// ->toArray();
return parent::getEloquentQuery() return parent::getEloquentQuery()
// ->join('odds_3ways', 'odds_3ways.event_id', '=', 'events.id')
->where('starttime', '>', Carbon::now()) ->where('starttime', '>', Carbon::now())
->where('sport_id', auth()->user()->sport_id); ->where('sport_id', auth()->user()->sport_id);
} }
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\Events\Tables;
use App\Filament\Tables\Columns\Odds3Way; use App\Filament\Tables\Columns\Odds3Way;
use Carbon\Carbon; use Carbon\Carbon;
use Filament\Actions\BulkActionGroup; use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction; use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction; use Filament\Actions\EditAction;
use Filament\Support\Enums\FontWeight; use Filament\Support\Enums\FontWeight;
@@ -42,13 +43,14 @@ class EventsTable
TextColumn::make('home.name')->alignRight()->searchable(), TextColumn::make('home.name')->alignRight()->searchable(),
TextColumn::make('away.name')->searchable(), TextColumn::make('away.name')->searchable(),
Odds3Way::make('odds_3way')->label('Market 1X2'), Odds3Way::make('odds_3way.bookmaker')->label('1X2'),
]) ])
->filters([ ->filters([
// //
]) ])
->recordActions([ ->recordActions([
// EditAction::make(), // EditAction::make(),
DeleteAction::make()->iconButton(),
]) ])
->toolbarActions([ ->toolbarActions([
BulkActionGroup::make([ BulkActionGroup::make([
@@ -13,7 +13,7 @@ class EditMultiline extends EditRecord
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
DeleteAction::make(), // DeleteAction::make(),
]; ];
} }
} }
@@ -13,9 +13,9 @@ class ListMultilines extends ListRecords
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
CreateAction::make() // CreateAction::make()
->createAnother(false) // ->createAnother(false)
->hidden(! auth()->user()->super_admin), // ->hidden(! auth()->user()->super_admin),
]; ];
} }
} }
@@ -7,7 +7,10 @@ use Filament\Actions\Action;
use Filament\Actions\EditAction; use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class MultilinesTable class MultilinesTable
{ {
@@ -20,6 +23,7 @@ class MultilinesTable
->label($isReordering ? 'Disable reordering' : 'Enable reordering'), ->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
) )
->reorderable('sort') ->reorderable('sort')
->defaultGroup('bettype.name')
->columns([ ->columns([
IconColumn::make('sport.icon') IconColumn::make('sport.icon')
->label('') ->label('')
@@ -33,16 +37,25 @@ class MultilinesTable
TextColumn::make('bookmaker.name'), TextColumn::make('bookmaker.name'),
BookmakerIcon::make('bookmaker.icon')->label('Icon'), BookmakerIcon::make('bookmaker.icon')->label('Icon'),
]) ])
->defaultSort('sort')
->deferFilters(false)
->filters([ ->filters([
// SelectFilter::make('sport_id')
]) ->label('Sport')
->default(1)
->selectablePlaceholder(false)
->relationship('sport', 'name', fn (Builder $query) => $query->where('is_active', 1))
->preload(),
], FiltersLayout::AboveContent)
->hiddenFilterIndicators()
->persistFiltersInSession()
->recordActions([ ->recordActions([
EditAction::make() // EditAction::make()
->mutateDataUsing(function (array $data): array { // ->mutateDataUsing(function (array $data): array {
$data['client_id'] = auth()->user()->client_id; // $data['client_id'] = auth()->user()->client_id;
return $data; // return $data;
}), // }),
]); ]);
} }
} }
+13
View File
@@ -2,9 +2,22 @@
namespace App\Filament\Tables\Columns; namespace App\Filament\Tables\Columns;
use App\Actions\MultilineSlots;
use Filament\Tables\Columns\Column; use Filament\Tables\Columns\Column;
class Odds3Way extends Column class Odds3Way extends Column
{ {
protected string $view = 'filament.tables.columns.odds3-way'; protected string $view = 'filament.tables.columns.odds3-way';
protected ?array $multiline;
public function loadMultiline(&$data)
{
$this->multiline = MultilineSlots::addSlots($data, 1, 1);
}
public function getMultiline(): ?array
{
return $this->multiline;
}
} }
+1 -10
View File
@@ -52,15 +52,6 @@ class Event extends Model
public function odds_3way() public function odds_3way()
{ {
$_bookmaker = Multiline::where('sport_id', auth()->user()->sport_id) return $this->hasMany(Odds3way::class, 'event_id', 'id')->with('bookmaker');
->where('client_id', auth()->user()->client_id)
->where('bettype_id', 1)
->where('matchpart_id', 1)
->pluck('bookmaker_id');
return $this->hasMany(Odds3way::class, 'event_id', 'id')
->join('multilines', 'multilines.bookmaker_id', 'odds_3ways.bookmaker_id')
->orderBy('multilines.sort');
// return $this->hasMany(Odds3way::class, 'event_id', 'id')->whereIn('bookmaker_id', $_bookmaker);
} }
} }
+6
View File
@@ -2,6 +2,7 @@
namespace App\Models; namespace App\Models;
use App\Models\Scopes\ClientScope;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Multiline extends Model class Multiline extends Model
@@ -34,4 +35,9 @@ class Multiline extends Model
{ {
return $this->belongsTo(Bookmaker::class, 'bookmaker_id', 'txid'); return $this->belongsTo(Bookmaker::class, 'bookmaker_id', 'txid');
} }
protected static function booted(): void
{
static::addGlobalScope(new ClientScope);
}
} }
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Models\Scopes;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
class ClientScope implements Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*/
public function apply(Builder $builder, Model $model): void
{
if (auth()->hasUser()) {
$builder->where('client_id', auth()->user()->client_id);
}
}
}
+3 -3
View File
@@ -4,10 +4,10 @@ namespace App\Utilities;
class BkmIconMap class BkmIconMap
{ {
public static function get($bookmaker) public static function get($image)
{ {
if ($bookmaker) { if ($image) {
return asset("storage/bookmaker-icons/$bookmaker->icon.png"); return asset("storage/bookmaker-icons/$image.png");
} else { } else {
return asset('storage/bookmaker-icons/missing.png'); return asset('storage/bookmaker-icons/missing.png');
} }
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Utilities;
class OddsFormatting
{
public static function get($odd, $stellen = 2)
{
if ($odd != 0) {
return number_format($odd, $stellen);
}
}
}
+9 -9
View File
@@ -551,7 +551,7 @@ app('router')->setCompiledRoutes(
array ( array (
0 => 0 =>
array ( array (
'_route' => 'generated::utvoDsmittGErgFU', '_route' => 'generated::9qxzN4LxsImcAiTa',
), ),
1 => NULL, 1 => NULL,
2 => 2 =>
@@ -571,7 +571,7 @@ app('router')->setCompiledRoutes(
array ( array (
0 => 0 =>
array ( array (
'_route' => 'generated::UKTOkgCt6yIOAG79', '_route' => 'generated::YrE3dbXP33LwuSFL',
), ),
1 => NULL, 1 => NULL,
2 => 2 =>
@@ -610,7 +610,7 @@ app('router')->setCompiledRoutes(
array ( array (
0 => 0 =>
array ( array (
'_route' => 'generated::qXNgDXoLuA95HjrL', '_route' => 'generated::uI3Rq0Z4wGl7G9CC',
), ),
1 => NULL, 1 => NULL,
2 => 2 =>
@@ -2600,7 +2600,7 @@ app('router')->setCompiledRoutes(
'waitSeconds' => NULL, 'waitSeconds' => NULL,
'withTrashed' => false, 'withTrashed' => false,
), ),
'generated::utvoDsmittGErgFU' => 'generated::9qxzN4LxsImcAiTa' =>
array ( array (
'methods' => 'methods' =>
array ( array (
@@ -2612,7 +2612,7 @@ app('router')->setCompiledRoutes(
array ( array (
'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile', 'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile',
'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile', 'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile',
'as' => 'generated::utvoDsmittGErgFU', 'as' => 'generated::9qxzN4LxsImcAiTa',
), ),
'fallback' => false, 'fallback' => false,
'defaults' => 'defaults' =>
@@ -2628,7 +2628,7 @@ app('router')->setCompiledRoutes(
'waitSeconds' => NULL, 'waitSeconds' => NULL,
'withTrashed' => false, 'withTrashed' => false,
), ),
'generated::UKTOkgCt6yIOAG79' => 'generated::YrE3dbXP33LwuSFL' =>
array ( array (
'methods' => 'methods' =>
array ( array (
@@ -2640,7 +2640,7 @@ app('router')->setCompiledRoutes(
array ( array (
'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps', 'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps',
'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps', 'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps',
'as' => 'generated::UKTOkgCt6yIOAG79', 'as' => 'generated::YrE3dbXP33LwuSFL',
), ),
'fallback' => false, 'fallback' => false,
'defaults' => 'defaults' =>
@@ -2711,7 +2711,7 @@ app('router')->setCompiledRoutes(
'waitSeconds' => NULL, 'waitSeconds' => NULL,
'withTrashed' => false, 'withTrashed' => false,
), ),
'generated::qXNgDXoLuA95HjrL' => 'generated::uI3Rq0Z4wGl7G9CC' =>
array ( array (
'methods' => 'methods' =>
array ( array (
@@ -2740,7 +2740,7 @@ app('router')->setCompiledRoutes(
\'exception\' => $exception, \'exception\' => $exception,
]), status: $exception ? 500 : 200); ]), status: $exception ? 500 : 200);
}";s:5:"scope";s:54:"Illuminate\\Foundation\\Configuration\\ApplicationBuilder";s:4:"this";N;s:4:"self";s:32:"0000000000000e030000000000000000";}}', }";s:5:"scope";s:54:"Illuminate\\Foundation\\Configuration\\ApplicationBuilder";s:4:"this";N;s:4:"self";s:32:"0000000000000e030000000000000000";}}',
'as' => 'generated::qXNgDXoLuA95HjrL', 'as' => 'generated::uI3Rq0Z4wGl7G9CC',
), ),
'fallback' => false, 'fallback' => false,
'defaults' => 'defaults' =>
+4 -7
View File
@@ -5,6 +5,10 @@
@source '../../../../resources/views/filament/pages/**/*'; @source '../../../../resources/views/filament/pages/**/*';
@source '../../../../vendor/awcodes/light-switch/resources/**/*.blade.php'; @source '../../../../vendor/awcodes/light-switch/resources/**/*.blade.php';
button[wire\:click="resetTableFiltersForm"] {
display: none;
}
.oddsbox .bl { .oddsbox .bl {
border-left: 1px solid #e4e4e7; border-left: 1px solid #e4e4e7;
} }
@@ -55,11 +59,4 @@
width: 50px; width: 50px;
color: #90a1b9; color: #90a1b9;
} }
}
/**
BOOKMAKER ICONS
*/
.b30 {
background-image: url('../book-icons/bet365.png');
} }
@@ -1,17 +1,23 @@
<?php <?php
use App\Utilities\BkmIconMap; use App\Utilities\BkmIconMap;
use App\Utilities\OddsFormatting;
?> ?>
<div {{ $getExtraAttributeBag() }} class="grid grid-cols-5 grid-rows-5 oddsbox"> <div {{ $getExtraAttributeBag() }} class="grid grid-cols-5 grid-rows-5 oddsbox">
@foreach ($record->odds_3way as $row)
<div class="bg-contain bg-center bg-no-repeat dark:opacity-85" title="{{ $row->bookmaker->txid }}" {{ $loadMultiline($record->odds_3way) }}
style="background-image: url('{{ BkmIconMap::get($row->bookmaker) }}')">
</div> @foreach ($getMultiline() as $row)
<div class="br bb">{{ number_format($row->h3w, 2) }}</div> @if (isset($row->bookmaker))
<div class="br bb">{{ number_format($row->d3w, 2) }}</div> <div class="bg-contain bg-center bg-no-repeat dark:opacity-90" title="{{ $row->bookmaker->txid }}"
<div class="br bb">{{ number_format($row->a3w, 2) }}</div> style="background-image: url('{{ BkmIconMap::get($row->bookmaker?->icon) }}')">
<div class="br bb">{{ $row->margin }}</div> </div>
<div class="br bb">{{ OddsFormatting::get($row->h3w, 2) }}&nbsp;</div>
<div class="br bb">{{ OddsFormatting::get($row->d3w, 2) }}&nbsp;</div>
<div class="br bb">{{ OddsFormatting::get($row->a3w, 2) }}&nbsp;</div>
<div class="br bb">{{ OddsFormatting::get($row->margin, 1) }}&nbsp;</div>
@endif
@endforeach @endforeach
</div> </div>
Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 28 KiB