This commit is contained in:
salam committed 2026-02-15 09:19:26 +01:00
1 parent 965c7fca90
commit d077b6a429
26 files changed
+134 -123

No files matched your search

+2 -1
View File
@@ -227,6 +227,7 @@ class Odds
$sport_id = (int) $row->group['spid'];
$event = [
'has_markets' => 1,
'provider_id' => (int) Nuh::$options['provider_id'],
'starttime' => $row->time,
'sport_id' => $sport_id,
@@ -237,7 +238,7 @@ class Odds
'competition_group_id' => (int) $row->group['cgid'],
];
$res = Event::firstOrCreate(['id' => (int) $row['id']], $event);
$res = Event::updateOrCreate(['id' => (int) $row['id']], $event);
if ($res) {
$event_id = $res->id;
}
@@ -62,6 +62,7 @@ class EventResource extends Resource
->with('event_bookmaker')
->with('event_user_star')
->with('event_user_note')
->where('has_markets', 1)
->where('sport_id', auth()->user()->sport_id);
if (config('env.app_env') == 'production') {
@@ -674,10 +674,10 @@ class EventsTable
])->iconButton()
->icon('phosphor-dots-three-vertical'),
])->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
]),
// ])->toolbarActions([
// BulkActionGroup::make([
// DeleteBulkAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
// ]),
]);
}
}
+6 -10
View File
@@ -9,14 +9,11 @@ use Illuminate\Support\Facades\Auth;
class LoadEvents
{
public static function load($search_left, $sport_id)
public static function load($search_values)
{
if ($search_left) {
$searchValues = preg_split('/\s+/', $search_left, -1, PREG_SPLIT_NO_EMPTY);
$element_ids = Element::where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
if ($search_values) {
$element_ids = Element::where(function ($query) use ($search_values) {
foreach ($search_values as $value) {
$query->orWhere('name', 'LIKE', '%'.$value.'%');
}
})->pluck('id')->toArray();
@@ -24,17 +21,16 @@ class LoadEvents
$query = Event::query()
->with('home')
->with('away')
->where('sport_id', $sport_id)
->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', $sport_id)
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now());
}
+2 -4
View File
@@ -18,14 +18,12 @@ class LoadProvider
if ($search_right) {
$searchValues = preg_split('/\s+/', $search_right, -1, PREG_SPLIT_NO_EMPTY);
return Mapper::query()
->where('starttime', '>', Carbon::now())
->where('sport_id', $user->sport_id)
->where('provider_id', $user->provider_id)
->where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
->where(function ($query) use ($search_right) {
foreach ($search_right as $value) {
$query->orWhere('home', 'LIKE', '%'.$value.'%')
->orWhere('away', 'LIKE', '%'.$value.'%');
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Livewire\Mapper;
class SearchString
{
public static function explode($string)
{
$string = str_replace([',', '/', '&'], '', $string);
return preg_split('/\s+/', $string, -1, PREG_SPLIT_NO_EMPTY);
}
}
+22 -26
View File
@@ -4,6 +4,7 @@ namespace App\Livewire;
use App\Filament\Tables\Columns\MapperLeftColumn;
use App\Livewire\Mapper\LoadEvents;
use App\Livewire\Mapper\SearchString;
use App\Livewire\Mapper\StoreMapped;
use App\Models\CompetitionGroup;
use App\Models\Country;
@@ -43,7 +44,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public $elements_swopped = false;
public $search_left = false;
public $search_values = [];
protected $listeners = [
'refreshMapperLeft' => '$refresh',
@@ -51,26 +52,18 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
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 = '';
if (($key = array_search($field, $this->search_values)) !== false) {
unset($this->search_values[$key]);
}
$this->dispatch('refreshMapperLeft');
}
#[Lazy]
public function table(Table $table): Table
{
return $table
->query(LoadEvents::load($this->search_left, auth()->user()->sport_id))
->query(LoadEvents::load($this->search_values))
->striped()
->columns([
IconColumn::make('country.icon')->icon(fn (string $state): string => $state)->label(''),
TextColumn::make('competition_group.name')->label('Group')
@@ -100,6 +93,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
FusedGroup::make([
Select::make('country_id')
->placeholder('Country')
->visible(fn () => auth()->user()->sport_id != 5)
->hiddenLabel()
->searchable()
->preload()
@@ -139,7 +133,6 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->label('')
->searchable()
->options(function (Get $get) {
$map = Country::all()->pluck('name', 'id')->toArray();
$query = CompetitionGroup::where('sport_id', auth()->user()->sport_id)
->whereHas('event', function ($query) {
@@ -150,6 +143,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
if ($get('country_id') ?? null) {
$res = $query->where('country_id', $get('country_id'))->get();
} else {
$timeframe = $get('starttime_period') ?? null;
if ($timeframe['start'] || $timeframe['end']) {
@@ -170,9 +164,14 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
}
});
}
$res = $query->groupBy('country_id')->get();
if (auth()->user()->sport_id != 5) {
$res = $query->groupBy('country_id')->get();
} else {
$res = $query->get();
}
}
$arr = [];
$map = Country::all()->pluck('name', 'id')->toArray();
foreach ($res as $value) {
if (isset($map[$value->country_id])) {
$arr[$value->id] = $map[$value->country_id].' '.$value->name;
@@ -233,9 +232,8 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
});
})->indicateUsing(function (): array {
$indicators = [];
if ($this->search_left) {
$searchValues = preg_split('/\s+/', $this->search_left, -1, PREG_SPLIT_NO_EMPTY);
foreach ($searchValues as $value) {
if ($this->search_values) {
foreach ($this->search_values as $value) {
$indicators[] = Indicator::make($value)->removeField($value)->color('info');
}
}
@@ -254,7 +252,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->icon('phosphor-x')
->size(Size::Small)
->action(function (Component $livewire) {
$this->search_left = '';
$this->search_values = [];
$this->tableSearch = ''; // Clears the main search bar
$livewire->fill(['tableSearch' => '']);
$livewire->resetTableFiltersForm(); // Clears all filters
@@ -271,12 +269,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
#[On('search_left')]
public function searchLeft($str)
{
$this->search_values = SearchString::explode($str);
foreach ($this->tableFilters['events'] as $key => $value) {
$this->tableFilters['events'][$key] = null;
}
$this->search_left = $str;
// foreach ($this->search_values as $key => $value) {
// $this->tableFilters['events'][$key] = null;
// }
$this->dispatch('refreshMapperLeft');
}
@@ -295,8 +292,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
})
->action(function ($arguments) {
StoreMapped::store($arguments, $this->elements_swopped);
$this->search_right = '';
$this->search_left = '';
$this->search_values = [];
$this->dispatch('refreshMapperLeft');
$this->dispatch('refreshMapperRight');
+16 -24
View File
@@ -4,6 +4,7 @@ namespace App\Livewire;
use App\Filament\Tables\Columns\MapperRightColumn;
use App\Livewire\Mapper\LoadProvider;
use App\Livewire\Mapper\SearchString;
use App\Livewire\Mapper\StoreMapped;
use App\Models\Country;
use App\Models\Event;
@@ -42,7 +43,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public $elements_swopped = false;
public $search_right = false;
public $search_values = [];
protected $listeners = [
'refreshMapperRight' => '$refresh',
@@ -50,16 +51,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
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 = '';
if (($key = array_search($field, $this->search_values)) !== false) {
unset($this->search_values[$key]);
}
$this->dispatch('refreshMapperRight');
@@ -68,7 +61,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
return $table
->query(LoadProvider::load($this->search_right, auth()->user()))
->query(LoadProvider::load($this->search_values, auth()->user()))
->striped()
->columns([
MapperRightColumn::make('right')->label(''),
TextColumn::make('starttime')
@@ -93,7 +87,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->schema([
FusedGroup::make([
Select::make('country_id')
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]) && auth()->user()->sport_id != 5)
->placeholder('Country')
->hiddenLabel()
->label('')
@@ -257,9 +251,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
});
})->indicateUsing(function (): array {
$indicators = [];
if ($this->search_right) {
$searchValues = preg_split('/\s+/', $this->search_right, -1, PREG_SPLIT_NO_EMPTY);
foreach ($searchValues as $value) {
if ($this->search_values) {
foreach ($this->search_values as $value) {
$indicators[] = Indicator::make($value)->removeField($value)->color('info');
}
}
@@ -283,7 +276,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->icon('phosphor-x')
->size(Size::Small)
->action(function (Component $livewire) {
$this->search_right = '';
$this->search_values = [];
$this->tableSearch = ''; // Clears the main search bar
$livewire->fill(['tableSearch' => '']);
$livewire->resetTableFiltersForm(); // Clears all filters
@@ -301,11 +294,11 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
#[On('search_right')]
public function searchRight($str)
{
foreach ($this->tableFilters['events'] as $key => $value) {
$this->tableFilters['events'][$key] = null;
}
$this->search_values = SearchString::explode($str);
$this->search_right = $str;
// foreach ($this->tableFilters['events'] as $key => $value) {
// $this->tableFilters['events'][$key] = null;
// }
$this->dispatch('refreshMapperRight');
}
@@ -324,8 +317,7 @@ 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->search_values = [];
$this->dispatch('refreshMapperLeft');
$this->dispatch('refreshMapperRight');
})
@@ -345,6 +337,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public function render()
{
return view('livewire.mapper-left');
return view('livewire.mapper-right');
}
}
+1
View File
@@ -8,6 +8,7 @@ class Event extends Model
{
protected $fillable = [
'id',
'has_markets',
'provider_id',
'betsapi_id',
'betradar_id',