This commit is contained in:
salam committed 2026-01-21 13:35:16 +01:00
1 parent f59ac10c2a
commit 7a9eeb8aad
25 files changed
+253 -78

No files matched your search

@@ -58,7 +58,8 @@ class EventResource extends Resource
->with('country')
->with('home')
->with('away')
->with('event_user_star');
->with('event_user_star')
->where('sport_id', auth()->user()->sport_id);
if (in_array('odds_2ways', EventsTable::$bettype_settings)) {
$query->with('odds_2ways.bookmaker');
@@ -68,6 +69,7 @@ class EventResource extends Resource
}
if (in_array('odds_3ways', EventsTable::$bettype_settings)) {
$query->with('odds_3ways.bookmaker');
// $query->with('odds_3ways.comparing_bookmaker');
}
if (in_array('odds_3ways_ht', EventsTable::$bettype_settings)) {
$query->with('odds_3ways_ht.bookmaker');
@@ -18,12 +18,14 @@ use App\Filament\Tables\Columns\ColumnTq;
use App\Filament\Tables\Columns\EventColumn;
use App\Filament\Tables\Columns\MatchIds;
use App\Models\BettypeUser;
use App\Models\ComparingBookmaker;
use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use App\Models\EventUserStar;
use App\Models\Group;
use App\Models\MultilineClient;
use App\Models\MultilineSetting;
use App\Models\Sport;
use App\Models\User;
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
@@ -54,16 +56,40 @@ class EventsTable
public static $multiline_gettype = [];
public static $user;
public static function load_multiline_bookmaker()
{
$res = MultilineClient::with('multiline_setting')
->select('bookmaker_id', 'multiline_setting_id')
->orderBy('sort')
->get();
if (self::$user->is_multiline_direct) {
foreach ($res as $value) {
$table = $value->multiline_setting->table;
self::$multiline_gettype[$table][] = (int) $value->bookmaker_id;
if (self::$user->sport_id == 1) {
$cb = ComparingBookmaker::where('sport_id', 1)->where('client_bookmaker_id', self::$user->bookmaker_id)->select('sorting', 'bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')->get();
} else {
$cb = ComparingBookmaker::where('sport_id', '!=', 1)->where('client_bookmaker_id', self::$user->bookmaker_id)->select('sorting', 'bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')->get();
}
$bookmakers = [];
foreach ($cb as $value) {
$bookmakers[] = $value->bookmaker_id;
}
$res = MultilineSetting::where('sport_id', self::$user->sport_id)->get();
foreach ($res as $value) {
self::$multiline_gettype[$value->table]['filter'] = $cb;
self::$multiline_gettype[$value->table]['bookmaker'] = $bookmakers;
}
} else {
$res = MultilineClient::with('multiline_setting')
->select('bookmaker_id', 'multiline_setting_id')
->orderBy('sort')
->get();
foreach ($res as $value) {
$table = $value->multiline_setting->table;
self::$multiline_gettype[$table]['bookmaker'][] = (int) $value->bookmaker_id;
}
}
}
@@ -81,6 +107,8 @@ class EventsTable
public static function configure(Table $table): Table
{
self::$user = User::getUser();
self::load_bettype_settings();
self::load_multiline_bookmaker();
@@ -109,7 +137,7 @@ class EventsTable
TextColumn::make('country.name')
->wrap()
->hidden(fn () => auth()->user()->sport_id == 5)
->hidden(fn () => self::$user->sport_id == 5)
->color('gray')
->icon(fn ($record) => $record->country?->icon),
@@ -214,8 +242,8 @@ class EventsTable
->columns(5)->columnSpan(5)
->schema([
Select::make(name: 'sport_id')
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->default(self::$user->sport_id)
->prefixIcon(self::$user->sport->icon)
->selectablePlaceholder(false)
->hiddenLabel()
->preload()
@@ -226,9 +254,7 @@ class EventsTable
->reactive()
->afterStateUpdated(function (callable $set, $state, $livewire) {
auth()->user()->sport_id = (int) $state;
User::where('id', auth()->user()->id)->update(['sport_id' => (int) $state]);
User::where('id', self::$user->id)->update(['sport_id' => (int) $state]);
$livewire->dispatch('refreshBettypeMenu');
@@ -238,15 +264,15 @@ class EventsTable
}),
Select::make(name: 'country_id')
->hidden(fn () => auth()->user()->sport_id == 5)
->hidden(fn () => self::$user->sport_id == 5)
->placeholder('Country')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->preload()
->options(function (Get $get) {
$res = Event::where('sport_id', $get('sport_id'))->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
->options(function () {
$res = Event::where('sport_id', self::$user->sport_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->pluck('name', 'id');
})
@@ -256,7 +282,7 @@ class EventsTable
$set('competition_group_id', null);
}),
Select::make('competition_group_id')
->hidden(fn () => auth()->user()->sport_id == 5)
->hidden(fn () => self::$user->sport_id == 5)
->placeholder('League')
->hiddenLabel()
->label('')
@@ -264,9 +290,9 @@ class EventsTable
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::where('sport_id', $get('sport_id'))->with('country')->with('competition_group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
$res = Event::where('sport_id', self::$user->sport_id)->with('country')->with('competition_group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
} else {
$res = Event::where('sport_id', $get('sport_id'))->with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
$res = Event::where('sport_id', self::$user->sport_id)->with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
}
$arr = [];
foreach ($res as $val) {
@@ -278,7 +304,7 @@ class EventsTable
})
->live(),
Select::make('group_id')
->visible(fn () => auth()->user()->sport_id == 5)
->visible(fn () => self::$user->sport_id == 5)
->placeholder('Tournament')
->hiddenLabel()
->label('')
@@ -286,9 +312,9 @@ class EventsTable
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::with('country')->where('sport_id', $get('sport_id'))->with('group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
$res = Event::with('country')->where('sport_id', self::$user->sport_id)->with('group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
} else {
$res = Event::with('country')->where('sport_id', $get('sport_id'))->with('group')->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
$res = Event::with('country')->where('sport_id', self::$user->sport_id)->with('group')->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
}
$arr = [];
foreach ($res as $val) {
@@ -310,13 +336,9 @@ class EventsTable
->query(function (Builder $query, array $data): Builder {
return $query
->when(
auth()->user()->stars,
self::$user->stars,
fn (Builder $query) => $query->whereHas('event_user_star')
)
->when(
$data['sport_id'],
fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
)
->when(
$data['country_id'],
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
@@ -418,20 +440,20 @@ class EventsTable
->tooltip('Add to favorits')
->action(function ($record) {
$res = EventUserStar::where('event_id', $record->id)
->where('user_id', auth()->user()->id)
->where('user_id', self::$user->id)
->first();
if ($res) {
EventUserStar::find($res->id)->delete();
} else {
EventUserStar::insert(['event_id' => $record->id, 'user_id' => auth()->user()->id]);
EventUserStar::insert(['event_id' => $record->id, 'user_id' => self::$user->id]);
}
}),
ActionGroup::make([
// EditAction::make(),
DeleteAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
DeleteAction::make()->visible(fn () => self::$user->hasRole('super_admin')),
Action::make('txodds_odds')
->label('TxOdds')
->disabled(fn () => ! auth()->user()->hasRole('super_admin'))
->disabled(fn () => ! self::$user->hasRole('super_admin'))
->icon('phosphor-arrow-square-out')
->url(fn ($record): string => route('txodds_odds', ['sportid' => $record->sport_id, 'txoddsid' => $record->id]))
->openUrlInNewTab(),
@@ -439,7 +461,7 @@ class EventsTable
->icon('phosphor-dots-three-vertical'),
])->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
DeleteBulkAction::make()->visible(fn () => self::$user->hasRole('super_admin')),
]),
]);
}
+9 -3
View File
@@ -20,8 +20,6 @@ class Column3way extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,11 +27,12 @@ class Column3way extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
{
$this->has_data = count($record->odds_3ways) ? true : false;
$this->act = $record->odds_3ways->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
@@ -49,6 +48,13 @@ class Column3way extends Column
$this->min['d3w'] = $record->odds_3ways->min('d3w');
$this->min['a3w'] = $record->odds_3ways->min('a3w');
// $record->odds_3ways = $record->odds_3ways->filter(function (int $value, int $key) {
// return in_array($this->bookmakers['bookmaker'], $value['bookmaker_id']);
// });
}
public function getAct()
+1 -3
View File
@@ -20,8 +20,6 @@ class Column3wayHt extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class Column3wayHt extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnDc extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnDc extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnDnb extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnDnb extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnGgng extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnGgng extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnMl extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnMl extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnMlS1 extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnMlS1 extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnPoint extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnPoint extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
@@ -20,8 +20,6 @@ class ColumnPointQ1 extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnPointQ1 extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnTotal extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnTotal extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
@@ -20,8 +20,6 @@ class ColumnTotalHt extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnTotalHt extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
@@ -20,8 +20,6 @@ class ColumnTotalQ1 extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnTotalQ1 extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
+1 -3
View File
@@ -20,8 +20,6 @@ class ColumnTq extends Column
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
@@ -29,7 +27,7 @@ class ColumnTq extends Column
public function getBookmaker(): ?array
{
return $this->bookmakers;
return $this->bookmakers['bookmaker'] ?? [];
}
public function loadData($record)
@@ -0,0 +1,25 @@
<?php
namespace App\Filament\Tables\Columns\Tools;
class Compare3way
{
public static function run($odds_3ways, $bookmakers)
{
return;
$maxrows = 4;
$count = 1;
$tmp = [];
dd($bookmakers);
foreach ($bookmakers as $bookmaker) {
$odds_3ways = $odds_3ways->filter(function ($odds_3ways, $bookmaker) {
if ($odds_3ways->contains('bookmaker_id', $bookmaker['bookmaker_id'])) {
return true;
}
return false;
});
}
}
}
+7
View File
@@ -52,4 +52,11 @@ class BettypeToggle extends Component
$this->dispatch('refreshBettypeMenu');
}
public function toggleMultiline()
{
User::where('id', auth()->user()->id)->update(['is_multiline_direct' => DB::raw('!is_multiline_direct')]);
$this->dispatch('refreshBettypeMenu');
}
}
+5
View File
@@ -32,6 +32,11 @@ class Odds3way extends Model
'oddchange_at',
];
public function comparing_bookmaker()
{
return $this->hasOne(ComparingBookmaker::class, 'bookmaker_id', 'bookmaker_id')->where('comparing_bookmakers.sport_id', auth()->user()->sport_id);
}
public function event()
{
return $this->belongsTo(Event::class);
+2
View File
@@ -34,6 +34,8 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
'app_verified_at',
'client_id',
'sport_id',
'star',
'is_multiline_direct',
'bookmaker_id',
'provider_id',
];
@@ -26,6 +26,7 @@ return new class extends Migration
$table->text('app_authentication_recovery_codes')->nullable();
$table->boolean('has_email_authentication')->default(false);
$table->boolean('stars')->default(false);
$table->boolean('is_multiline_direct')->default(false);
$table->timestamp('app_verified_at')->nullable();
$table->rememberToken();
@@ -11,10 +11,42 @@
@include('filament.tables.columns.multiline.label', ['labels' => ['1X', '12', 'X2']])
@foreach ($record->odds_dc as $item)
@if ($item->bookmaker_id == auth()->user()->bookmaker_id)
@include('filament.tables.columns.multiline.bkm', [
'bookmaker_id' => $item->bookmaker_id,
'icon' => $item->bookmaker->icon ?? '',
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->dc1x,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->dc12,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->dcx2,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->margin,
'dec' => 1,
'has' => false,
])
@endif
@endforeach
@foreach ($getBookmaker() as $bookmaker_id)
@foreach ($record->odds_dc as $item)
@if ($item->bookmaker_id == $bookmaker_id)
@include('filament.tables.columns.multiline.bkm', [
'bookmaker_id' => $item->bookmaker_id,
'icon' => $item->bookmaker->icon ?? '',
@@ -1,6 +1,6 @@
@php
$loadData($record);
$act = $getAct();
$act = $getAct();
@endphp
@if ($hasData())
@@ -11,10 +11,36 @@
@include('filament.tables.columns.multiline.label', ['labels' => ['H', 'A']])
@foreach ($record->odds_tq as $item)
@if ($item->bookmaker_id == auth()->user()->bookmaker_id)
@include('filament.tables.columns.multiline.bkm', [
'bookmaker_id' => $item->bookmaker_id,
'icon' => $item->bookmaker->icon ?? '',
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->htq,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->atq,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->margin,
'dec' => 1,
'has' => false,
])
@endif
@endforeach
@foreach ($getBookmaker() as $bookmaker_id)
@foreach ($record->odds_tq as $item)
@if ($item->bookmaker_id == $bookmaker_id)
@include('filament.tables.columns.multiline.bkm', [
'bookmaker_id' => $item->bookmaker_id,
'icon' => $item->bookmaker->icon ?? '',
@@ -11,6 +11,39 @@
@include('filament.tables.columns.multiline.label', ['labels' => ['1', 'X', '2']])
@foreach ($record->odds_3ways as $item)
@if ($item->bookmaker_id == auth()->user()->bookmaker_id)
@include('filament.tables.columns.multiline.bkm', [
'bookmaker_id' => $item->bookmaker_id,
'icon' => $item->bookmaker->icon ?? '',
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->h3w,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->d3w,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->a3w,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->margin,
'dec' => 1,
'has' => false,
])
@endif
@endforeach
@foreach ($getBookmaker() as $bookmaker_id)
@foreach ($record->odds_3ways as $item)
@if ($item->bookmaker_id == $bookmaker_id)
@@ -1,6 +1,6 @@
@php
$loadData($record);
$act = $getAct();
$act = $getAct();
@endphp
@if ($hasData())
@@ -11,10 +11,42 @@
@include('filament.tables.columns.multiline.label', ['labels' => ['1', 'X', '2']])
@foreach ($record->odds_3ways_ht as $item)
@if ($item->bookmaker_id == auth()->user()->bookmaker_id)
@include('filament.tables.columns.multiline.bkm', [
'bookmaker_id' => $item->bookmaker_id,
'icon' => $item->bookmaker->icon ?? '',
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->h3w,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->d3w,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->a3w,
'dec' => 2,
'has' => false,
])
@include('filament.tables.columns.multiline.odds', [
'odd' => $item->margin,
'dec' => 1,
'has' => false,
])
@endif
@endforeach
@foreach ($getBookmaker() as $bookmaker_id)
@foreach ($record->odds_3ways_ht as $item)
@if ($item->bookmaker_id == $bookmaker_id)
@include('filament.tables.columns.multiline.bkm', [
'bookmaker_id' => $item->bookmaker_id,
'icon' => $item->bookmaker->icon ?? '',
@@ -5,6 +5,12 @@
<div class="m-0 p-0">{{ $toggle['short'] }}</div>
</x-filament::button>
@endforeach
<x-filament::button size="xs" outlined color="gray" wire:click="toggleStar" :color="auth()->user()->stars ? 'primary' : 'gray'" :icon="auth()->user()->stars ? 'phosphor-star-fill' : 'phosphor-star'">
<x-filament::button size="xs"
tooltip="
Toggle multiline between 'Comparing Bookmaker List' or 'Fixed Bookmaker'"
wire:click="toggleMultiline" :color="auth()->user()->is_multiline_direct ? 'primary' : 'gray'" icon='phosphor-list'>
</x-filament::button>
<x-filament::button size="xs" wire:click="toggleStar" :color="auth()->user()->stars ? 'primary' : 'gray'" :icon="auth()->user()->stars ? 'phosphor-star-fill' : 'phosphor-star'">
</x-filament::button>
</div>