34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Mapper;
|
|
|
|
use App\Models\Mapper;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class LoadProvider
|
|
{
|
|
public static function load($search_right, $user)
|
|
{
|
|
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) {
|
|
$query->orWhere('home', 'LIKE', '%'.$value.'%')
|
|
->orWhere('away', 'LIKE', '%'.$value.'%');
|
|
}
|
|
});
|
|
} else {
|
|
return Mapper::query()
|
|
->where('starttime', '>', Carbon::now())
|
|
->where('sport_id', $user->sport_id)
|
|
->where('provider_id', $user->provider_id);
|
|
}
|
|
}
|
|
}
|