mapper ok
This commit is contained in:
1 parent
2e57e49f08
commit
c617935e2f
18 files changed
+227
-97
No files matched your search
@@ -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([
|
||||
//
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user