42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Mapper;
|
|
|
|
use App\Models\Event;
|
|
use App\Models\Mapper;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class LoadProvider
|
|
{
|
|
public static function load($search_values)
|
|
{
|
|
|
|
$res = Event::query()->where('betradar_id', '>', 0)->pluck('betradar_id');
|
|
|
|
// XXX
|
|
// foreach ($res as $betradar_id) {
|
|
// Mapper::where('betradar_id', $betradar_id)->delete();
|
|
// }
|
|
|
|
if (is_array($search_values) and \count($search_values)) {
|
|
|
|
return Mapper::query()
|
|
->whereDate('starttime', '>', Carbon::now())
|
|
->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()
|
|
->whereDate('starttime', '>', Carbon::now())
|
|
->where('sport_id', auth()->user()->sport_id)
|
|
->where('provider_id', auth()->user()->provider_id);
|
|
}
|
|
}
|
|
}
|