wip
This commit is contained in:
1 parent
965c7fca90
commit
d077b6a429
26 files changed
+134
-123
No files matched your search
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user