country = request()->route('country', config('app.domain_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),
];
}
}; ?>
{{ __('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
@if(auth()->check() && $course->created_by === auth()->id())
{{ __('Bearbeiten') }}
{{ __('Neues Event erstellen') }}
@elseif(!auth()->check())
{{ __('Log in') }}
@endif
@endforeach