39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Mapper;
|
|
|
|
use App\Models\Event;
|
|
use App\Models\Mapper;
|
|
|
|
class LoadMapper
|
|
{
|
|
public static function load($search_values)
|
|
{
|
|
|
|
$res = Event::query()->where('betradar_id', '>', 0)->pluck('betradar_id');
|
|
|
|
foreach ($res as $betradar_id) {
|
|
Mapper::where('betradar_id', $betradar_id)->delete();
|
|
}
|
|
|
|
if (is_array($search_values) and \count($search_values)) {
|
|
|
|
return Mapper::query()
|
|
->where('sport_id', auth()->user()->sport_id)
|
|
->where('provider_id', auth()->user()->provider_id)
|
|
->where(function ($query) use ($search_values) {
|
|
foreach ($search_values as $value) {
|
|
$query->orWhere('home', 'LIKE', '%'.$value.'%')
|
|
->orWhere('away', 'LIKE', '%'.$value.'%');
|
|
}
|
|
});
|
|
|
|
} else {
|
|
return Mapper::query()
|
|
->with('country_magloo')
|
|
->where('sport_id', auth()->user()->sport_id)
|
|
->where('provider_id', auth()->user()->provider_id);
|
|
}
|
|
}
|
|
}
|