mapper ok

This commit is contained in:
salam committed 2026-01-06 13:09:18 +01:00
1 parent 2e57e49f08
commit c617935e2f
18 files changed
+227 -97

No files matched your search

+1 -1
View File
@@ -131,7 +131,7 @@ class Odds
// one week per group names (mybee fastes)
$groupids = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->groupBy('group_id')->pluck('group_id');
foreach ($groupids as $groupid) {
$_calls[] = $url = 'https://xml2.txodds.com/feed/odds/xml.php?'.Nuh::$AUTHTOKEN.'&all_odds=2&ot='.$markets.'&days=0,7&pgid='.$groupid;
$_calls[] = $url = 'https://xml2.txodds.com/feed/odds/xml.php?'.Nuh::$AUTHTOKEN.'&all_odds=2&ot='.$markets.'&days=0,1&pgid='.$groupid;
}
} elseif (Nuh::$options['b']) {
// one day
@@ -4,11 +4,10 @@ namespace App\Filament\Clusters\Administrator;
use BackedEnum;
use Filament\Clusters\Cluster;
use Filament\Support\Icons\Heroicon;
class AdministratorCluster extends Cluster
{
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSquares2x2;
protected static string|BackedEnum|null $navigationIcon = 'phosphor-user';
protected static ?int $navigationSort = 3;
}
@@ -34,8 +34,6 @@ class ClientsTable
->wrap()
->color('warning')
->formatStateUsing(fn (string $state): string => Sport::where('id', $state)->pluck('name')->first()),
TextColumn::make('created_at')->dateTime(),
TextColumn::make('updated_at')->dateTime(),
])
->recordActions([
Action::make('multiline')
@@ -123,6 +123,7 @@ class EventsTable
self::load_multiline_bookmaker();
return $table
// ->poll('10s')
->striped()
->deferLoading()
->columns([
@@ -197,8 +198,8 @@ class EventsTable
->width(225)
->label('Totals'),
])->searchable(['id', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'magnig_id', 'magken_id', 'lognig_id', 'logcol_id'])
->poll('10s')
->defaultSort('starttime', 'ASC')
->extremePaginationLinks()
->filters([
Filter::make('events')
->schema([
@@ -25,14 +25,6 @@ class UsersTable
->label('Active Bookmaker')
->badge()
->color('warning'),
TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
+56 -6
View File
@@ -18,14 +18,19 @@ use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\Size;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\Indicator;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Attributes\Lazy;
use Livewire\Attributes\On;
use Livewire\Component;
#[Lazy]
class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
{
use InteractsWithActions;
@@ -34,14 +39,33 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public $elements_swopped = false;
public $search_left = false;
protected $listeners = [
'reload_data' => '$refresh',
'reload_data_left' => '$refresh',
];
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
{
$searchValues = preg_split('/\s+/', $this->search_left, -1, PREG_SPLIT_NO_EMPTY);
if (($key = array_search($field, $searchValues)) !== false) {
unset($searchValues[$key]);
}
if ($searchValues) {
$this->search_left = implode(' ', $searchValues);
} else {
$this->search_left = '';
}
$this->dispatch('reload_data_left');
}
public function table(Table $table): Table
{
return $table
->query(LoadEvents::load())
->query(LoadEvents::load($this->search_left))
->columns([
MapperLeftColumn::make('left')->label(''),
])
@@ -107,6 +131,16 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
);
})->indicateUsing(function (): array {
$indicators = [];
if ($this->search_left) {
$searchValues = preg_split('/\s+/', $this->search_left, -1, PREG_SPLIT_NO_EMPTY);
foreach ($searchValues as $value) {
$indicators[] = Indicator::make($value)->removeField($value);
}
}
return $indicators;
})
->columns(4)->columnSpan(4),
], layout: FiltersLayout::AboveContent)
@@ -116,12 +150,15 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->toolbarActions([
Action::make('reload_data_left')
->hiddenLabel()
->color('gray')
->icon('heroicon-o-arrow-path')
// ->icon('phosphor-x')
->icon('phosphor-x')
->color('danger')
->size(Size::Small)
->action(function (Component $livewire) {
$livewire->resetTableFiltersForm(); // Clears all filters
$this->search_left = '';
$this->tableSearch = ''; // Clears the main search bar
$livewire->fill(['tableSearch' => '']);
$livewire->resetTableFiltersForm(); // Clears all filters
$this->dispatch('reload_data_left');
}),
]);
}
@@ -131,6 +168,14 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
$this->elements_swopped = ! $this->elements_swopped;
}
#[On('search_left')]
public function searchLeft($str)
{
$this->search_left = $str;
$this->dispatch('reload_data_left');
}
public function leftAction(): Action
{
return Action::make('left')
@@ -145,6 +190,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
})
->action(function ($arguments) {
StoreMapped::store($arguments, $this->elements_swopped);
$this->search_right = '';
$this->search_left = '';
$this->dispatch('reload_data_left');
$this->dispatch('reload_data_right');
})
->closeModalByEscaping(false)
->modalCloseButton(false)
+71 -6
View File
@@ -16,16 +16,21 @@ use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\Size;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\Indicator;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Lazy;
use Livewire\Attributes\On;
use Livewire\Component;
#[Lazy]
class MapperRight extends Component implements HasActions, HasSchemas, HasTable
{
use InteractsWithActions;
@@ -34,14 +39,33 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public $elements_swopped = false;
public $search_right = false;
protected $listeners = [
'reload_data' => '$refresh',
'reload_data_right' => '$refresh',
];
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
{
$searchValues = preg_split('/\s+/', $this->search_right, -1, PREG_SPLIT_NO_EMPTY);
if (($key = array_search($field, $searchValues)) !== false) {
unset($searchValues[$key]);
}
if ($searchValues) {
$this->search_right = implode(' ', $searchValues);
} else {
$this->search_right = '';
}
$this->dispatch('reload_data_right');
}
public function table(Table $table): Table
{
return $table
->query(LoadProvider::load())
->query(LoadProvider::load($this->search_right))
->columns([
MapperRightColumn::make('right')->label(''),
])->searchable(['home', 'away'])
@@ -119,6 +143,16 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
$data['group_id'],
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
);
})->indicateUsing(function (): array {
$indicators = [];
if ($this->search_right) {
$searchValues = preg_split('/\s+/', $this->search_right, -1, PREG_SPLIT_NO_EMPTY);
foreach ($searchValues as $value) {
$indicators[] = Indicator::make($value)->removeField($value);
}
}
return $indicators;
})
->columns(4)->columnSpan(4),
], layout: FiltersLayout::AboveContent)
@@ -127,13 +161,17 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->filtersFormColumns(3)
->deferFilters(false)
->toolbarActions([
Action::make('reload_data')
Action::make('reload_data_right')
->hiddenLabel()
->color('gray')
->icon('heroicon-o-arrow-path')
->icon('phosphor-x')
->color('danger')
->size(Size::Small)
->action(function (Component $livewire) {
$livewire->resetTableFiltersForm(); // Clears all filters
$this->search_right = '';
$this->tableSearch = ''; // Clears the main search bar
$livewire->fill(['tableSearch' => '']);
$livewire->resetTableFiltersForm(); // Clears all filters
$this->dispatch('reload_data_right');
}),
]);
}
@@ -143,6 +181,29 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
$this->elements_swopped = ! $this->elements_swopped;
}
#[On('search_right')]
public function searchRight($str)
{
$this->search_right = $str;
$this->dispatch('reload_data_right');
}
// In the same Table class
protected function removeTableFilters(): void
{
// Custom logic before or after removing filters
// Example: Log the action
\Log::info('Custom filter removal logic triggered.');
// Call the parent method to perform the default removal
parent::removeTableFilters();
// Or, if you want full control, you can manually clear:
// $this->tableFilters = [];
// $this->dispatch('refresh-table');
}
public function rightAction(): Action
{
return Action::make('right')
@@ -156,6 +217,10 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper]);
})->action(function ($arguments) {
StoreMapped::store($arguments, $this->elements_swopped);
$this->search_right = '';
$this->search_left = '';
$this->dispatch('reload_data_left');
$this->dispatch('reload_data_right');
})
->closeModalByEscaping(false)
->modalCloseButton(false)
+3 -2
View File
@@ -25,7 +25,8 @@ class TopMenuItems extends Component
public $current = '';
protected $listeners = [
'reload_data' => '$refresh',
'reload_data_left' => '$refresh',
'reload_data_right' => '$refresh',
];
public function mount()
@@ -78,7 +79,7 @@ class TopMenuItems extends Component
{
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id]);
$this->dispatch('reload_data');
$this->dispatch('reload_data_right');
}
public function swopSport()
+27 -2
View File
@@ -2,16 +2,41 @@
namespace App\Mapper;
use App\Models\Element;
use App\Models\Event;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
class LoadEvents
{
public static function load()
public static function load($search_left)
{
if ($search_left) {
$query = Event::query()->where('sport_id', Auth::user()->sport_id)->where('starttime', '>', Carbon::now());
$searchValues = preg_split('/\s+/', $search_left, -1, PREG_SPLIT_NO_EMPTY);
$element_ids = Element::where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
$query->orWhere('name', 'LIKE', '%'.$value.'%');
}
})->pluck('id')->toArray();
$query = Event::query()
->with('home')
->with('away')
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where(function ($query) use ($element_ids) {
$query->orWhereIn('home_id', $element_ids)->orWhereIn('away_id', $element_ids);
});
} else {
$query = Event::query()
->with('home')
->with('away')
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now());
}
switch (Auth::user()->provider_id) {
case 2:
+21 -5
View File
@@ -8,11 +8,27 @@ use Illuminate\Support\Facades\Auth;
class LoadProvider
{
public static function load()
public static function load($search_right)
{
return Mapper::query()
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where('provider_id', Auth::user()->provider_id);
if ($search_right) {
$searchValues = preg_split('/\s+/', $search_right, -1, PREG_SPLIT_NO_EMPTY);
return Mapper::query()
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where('provider_id', Auth::user()->provider_id)
->where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
$query->orWhere('home', 'LIKE', '%'.$value.'%')
->orWhere('away', 'LIKE', '%'.$value.'%');
}
});
} else {
return Mapper::query()
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where('provider_id', Auth::user()->provider_id);
}
}
}
Generated
+8 -8
View File
@@ -9922,16 +9922,16 @@
},
{
"name": "laravel/pint",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/pint.git",
"reference": "69dcca060ecb15e4b564af63d1f642c81a241d6f"
"reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/69dcca060ecb15e4b564af63d1f642c81a241d6f",
"reference": "69dcca060ecb15e4b564af63d1f642c81a241d6f",
"url": "https://api.github.com/repos/laravel/pint/zipball/c67b4195b75491e4dfc6b00b1c78b68d86f54c90",
"reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90",
"shasum": ""
},
"require": {
@@ -9942,9 +9942,9 @@
"php": "^8.2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.90.0",
"illuminate/view": "^12.40.1",
"larastan/larastan": "^3.8.0",
"friendsofphp/php-cs-fixer": "^3.92.4",
"illuminate/view": "^12.44.0",
"larastan/larastan": "^3.8.1",
"laravel-zero/framework": "^12.0.4",
"mockery/mockery": "^1.6.12",
"nunomaduro/termwind": "^2.3.3",
@@ -9985,7 +9985,7 @@
"issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint"
},
"time": "2025-11-25T21:15:52+00:00"
"time": "2026-01-05T16:49:17+00:00"
},
{
"name": "laravel/sail",
@@ -21,8 +21,7 @@
@endif
</div>
@include('filament.tables.columns.parts.search-button', [
'target' => 'input-2',
@include('filament.tables.columns.parts.search-button-left', [
'find' => $record->home->name,
])
@@ -32,9 +31,9 @@
<div>{{ $record->id }}</div>
</div>
<div class="flex justify-center space-x-4">
<div class="text-right font-bold">{{ $record->home->name }}</div>
<div class="text-right font-bold text-wrap">{{ $record->home->name }}</div>
<div class="w-6 text-center">-</div>
<div class="text-left font-bold">{{ $record->away->name }}</div>
<div class="text-left font-bold text-wrap">{{ $record->away->name }}</div>
</div>
<div class="flex justify-center space-x-4 text-gray-600 dark:text-gray-500">
<div>{{ $record->country?->name }}</div>
@@ -43,8 +42,7 @@
</div>
@include('filament.tables.columns.parts.search-button', [
'target' => 'input-2',
@include('filament.tables.columns.parts.search-button-left', [
'find' => $record->away->name,
])
@@ -16,8 +16,7 @@
@include('filament.tables.columns.parts.move-botton')
@include('filament.tables.columns.parts.search-button', [
'target' => 'input-1',
@include('filament.tables.columns.parts.search-button-right', [
'find' => $record->home,
])
@@ -27,9 +26,9 @@
<div>{{ $record->event_id }}</div>
</div>
<div class="flex justify-center space-x-4">
<div class="text-right font-bold">{{ $record->home }}</div>
<div class="text-right font-bold text-wrap">{{ $record->home }}</div>
<div class="w-6 text-center">-</div>
<div class="text-left font-bold">{{ $record->away }}</div>
<div class="text-left font-bold text-wrap">{{ $record->away }}</div>
</div>
<div class="flex justify-center space-x-4 text-gray-600 dark:text-gray-500">
<div>{{ $record->country }}</div>
@@ -38,8 +37,7 @@
</div>
</div>
@include('filament.tables.columns.parts.search-button', [
'target' => 'input-1',
@include('filament.tables.columns.parts.search-button-right', [
'find' => $record->away,
])
@@ -0,0 +1,3 @@
<div class="my-auto">
<x-filament::button icon="phosphor-magnifying-glass" size="xs" x-on:click="search_right='{{ $find }}';" />
</div>
@@ -0,0 +1,3 @@
<div class="my-auto">
<x-filament::button icon="phosphor-magnifying-glass" size="xs" x-on:click="search_left='{{ $find }}'; " />
</div>
@@ -1,5 +0,0 @@
<div class="my-auto">
<x-filament::button icon="phosphor-magnifying-glass" color="gray" size="xs"
x-on:click="document.getElementById('{{ $target }}').focus();
document.getElementById('{{ $target }}').value = '{{ $find }}';" />
</div>
@@ -2,22 +2,12 @@
use Illuminate\Support\Carbon;
$e = Carbon::parse($event->starttime);
$m = Carbon::parse($mapper->starttime);
$seconds = $e->diffInSeconds($m);
$diff = gmdate('H:i:s', $seconds);
if ($seconds == 0) {
$color = 1;
} elseif ($seconds < 1800) {
$color = 2;
} elseif ($seconds < 7200) {
$color = 3;
} else {
$color = 4;
}
$seconds = $m->diffInSeconds($e);
$text = $m->diffForHumans($e, ['parts' => 4], true);
@endphp
<div>
@@ -26,23 +16,15 @@
<div>Startime Difference</div>
<div></div>
<div class="bg-gray-100 p-1 border rounded-lg">{{ $e->format('d-m-y H:i') }}</div>
@switch($color)
@case(1)
<div class="bg-green-100 text-green-500 p-1 border rounded-lg">{{ $diff }}</div>
@break
@case(2)
<div class="bg-blue-100 text-blue-500 p-1 border rounded-lg">{{ $diff }}</div>
@break
@case(3)
<div class="bg-amber-100 text-amber-500 p-1 border rounded-lg">{{ $diff }}</div>
@break
@case(4)
<div class="bg-red-100 text-red-500 p-1 border rounded-lg">{{ $diff }}</div>
@break
@endswitch
@if ($seconds == 0)
<div class="bg-green-100 text-green-500 p-1 border rounded-lg">Starttime is matching</div>
@elseif ($seconds < 1800 && $seconds > -1800)
<div class="bg-blue-100 text-blue-500 p-1 border rounded-lg">{{ $text }}</div>
@elseif ($seconds < 7200 && $seconds > -7200)
<div class="bg-amber-100 text-amber-500 p-1 border rounded-lg">{{ $text }}</div>
@else
<div class="bg-red-100 text-red-500 p-1 border rounded-lg">{{ $text }}</div>
@endif
<div class="bg-gray-100 p-1 border rounded-lg">{{ $m->format('d-m-y H:i') }}</div>
<div class="col-span-3 flex justify-center gap-2 mt-6">
<div>
@@ -74,10 +74,10 @@
{{-- Event Mapper --}}
<x-filament::modal width="7xl" icon="heroicon-o-squares-2x2" :close-by-clicking-away="false" :close-by-escaping="false"
<x-filament::modal width="7xl" icon="phosphor-arrows-in-line-horizontal" :close-by-clicking-away="false" :close-by-escaping="false"
:close-button="true">
<x-slot name="trigger">
<x-filament::button outlined icon="heroicon-o-squares-2x2" color="gray">
<x-filament::button outlined icon="phosphor-arrows-in-line-horizontal" color="gray">
Event Mapper
</x-filament::button>
</x-slot>
@@ -156,7 +156,9 @@
</div>
</x-slot>
<div id="mapper" class="grid grid-cols-2 gap-4 drag-and-drop text-sm" x-data="{ event_id: 0, match_id: 0, overleftcolumn: false, overrightcolumn: false }">
<div id="mapper" class="grid grid-cols-2 gap-4 drag-and-drop text-sm" x-data="{ search_left: '', search_right: '', event_id: 0, match_id: 0, overleftcolumn: false, overrightcolumn: false }"
x-init="$watch('search_left', value => Livewire.dispatch('search_left', value));
$watch('search_right', value => Livewire.dispatch('search_right', value));">
<div>
@livewire('mapper-left')
</div>
@@ -253,16 +255,18 @@
@if (auth()->user()->hasRole('konto_switch'))
<x-filament::dropdown>
<x-slot name="trigger">
<x-filament::button icon="phosphor-user">
<x-filament::button icon="phosphor-play">
{{ $client }}
</x-filament::button>
</x-slot>
<x-filament::dropdown.list>
@foreach ($clients as $id => $name)
<x-filament::dropdown.list.item wire:click="swop({{ $id }})" icon="phosphor-key">
{{ $name }}
</x-filament::dropdown.list.item>
@if ($name != $client)
<x-filament::dropdown.list.item wire:click="swop({{ $id }})" icon="phosphor-play">
{{ $name }}
</x-filament::dropdown.list.item>
@endif
@endforeach
</x-filament::dropdown.list>
</x-filament::dropdown>