mapper ok

This commit is contained in:
salam committed 2026-01-06 13:09:18 +01:00
1 parent 2e57e49f08
commit c617935e2f
18 files changed
+227 -97

No files matched your search

+27 -2
View File
@@ -2,16 +2,41 @@
namespace App\Mapper;
use App\Models\Element;
use App\Models\Event;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
class LoadEvents
{
public static function load()
public static function load($search_left)
{
if ($search_left) {
$query = Event::query()->where('sport_id', Auth::user()->sport_id)->where('starttime', '>', Carbon::now());
$searchValues = preg_split('/\s+/', $search_left, -1, PREG_SPLIT_NO_EMPTY);
$element_ids = Element::where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
$query->orWhere('name', 'LIKE', '%'.$value.'%');
}
})->pluck('id')->toArray();
$query = Event::query()
->with('home')
->with('away')
->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', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now());
}
switch (Auth::user()->provider_id) {
case 2: