country = request()->route('country'); } public function with(): array { return [ 'courses' => Course::with(['lecturer', 'createdBy']) ->withExists([ 'courseEvents as has_future_events' => fn($query) => $query->where('from', '>=', now()) ]) ->when($this->search, fn($query) => $query ->where('name', 'ilike', '%'.$this->search.'%') ->orWhere('description', 'ilike', '%'.$this->search.'%'), ) ->orderByDesc('has_future_events') ->paginate(15), ]; } }; ?>
{{ __('Kurse') }}
{{ __('Neuer Kurs') }}
{{ __('Name') }} {{ __('Dozent') }} {{ __('Nächster Termin') }} {{ __('Aktionen') }} @foreach ($courses as $course) @if($course->lecturer)
{{ $course->lecturer->name }}
@endif
@php $nextEvent = $course->courseEvents() ->where('from', '>=', now()) ->orderBy('from', 'asc') ->first(); @endphp @if($nextEvent) {{ $nextEvent->from->format('d.m.Y H:i') }} @endif {{ __('Bearbeiten') }} {{ __('Neues Event erstellen') }}
@endforeach