diff --git a/resources/views/livewire/courses/create-edit-events.blade.php b/resources/views/livewire/courses/create-edit-events.blade.php index 564bb84..4728300 100644 --- a/resources/views/livewire/courses/create-edit-events.blade.php +++ b/resources/views/livewire/courses/create-edit-events.blade.php @@ -1,5 +1,6 @@ country = request()->route('country'); @@ -69,10 +75,33 @@ new class extends Component { } } + public function createVenue(): void + { + $validated = $this->validate([ + 'newVenueName' => ['required', 'string', 'max:255', 'unique:venues,name'], + 'newVenueCityId' => ['required', 'exists:cities,id'], + 'newVenueStreet' => ['required', 'string', 'max:255'], + ]); + + $venue = Venue::create([ + 'name' => $validated['newVenueName'], + 'city_id' => $validated['newVenueCityId'], + 'street' => $validated['newVenueStreet'], + 'slug' => str($validated['newVenueName'])->slug(), + 'created_by' => auth()->id(), + ]); + + $this->venue_id = $venue->id; + $this->reset(['newVenueName', 'newVenueCityId', 'newVenueStreet']); + + \Flux\Flux::modal('add-venue')->close(); + } + public function with(): array { return [ 'venues' => Venue::query()->orderBy('name')->get(), + 'cities' => City::query()->orderBy('name')->get(), ]; } }; ?> @@ -105,7 +134,14 @@ new class extends Component { - {{ __('Veranstaltungsort') }} * +
+ {{ __('Veranstaltungsort') }} * + + + {{ __('Ort hinzufügen') }} + + +
@@ -159,4 +195,51 @@ new class extends Component { + + + +
+
+ {{ __('Veranstaltungsort hinzufügen') }} + {{ __('Füge einen neuen Veranstaltungsort zur Datenbank hinzu.') }} +
+ + + {{ __('Name') }} * + + + + + + {{ __('Stadt') }} * + + + + + @foreach($cities as $city) + {{ $city->name }} ({{ $city->country->name }}) + + @endforeach + + + + + + {{ __('Straße') }} * + + + + +
+ + + + {{ __('Abbrechen') }} + + + {{ __('Ort erstellen') }} +
+
+
diff --git a/resources/views/livewire/courses/landingpage.blade.php b/resources/views/livewire/courses/landingpage.blade.php index e504e64..7cccb7e 100644 --- a/resources/views/livewire/courses/landingpage.blade.php +++ b/resources/views/livewire/courses/landingpage.blade.php @@ -20,6 +20,7 @@ new class extends Component { 'course' => $this->course->load('lecturer'), 'events' => $this->course ->courseEvents() + ->with(['venue.city']) ->where('from', '>=', now()) ->orderBy('from', 'asc') ->get(), @@ -133,8 +134,22 @@ new class extends Component { {{ $event->venue->name }} + @if($event->venue->street) + + {{ $event->venue->street }} + @if($event->venue->city) + , {{ $event->venue->city->name }} + @endif + + @endif @endif + +
+ {{ $event->registrations->count() }} {{ __('Anmeldungen') }} +
+
+
country = request()->route('country'); } - public function sort($column) - { - if ($this->sortBy === $column) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortBy = $column; - $this->sortDirection = 'asc'; - } - } - public function with(): array { return [ 'meetups' => Meetup::with(['city.country', 'createdBy']) + ->withExists([ + 'meetupEvents as has_future_events' => fn($query) => $query->where('start', '>=', now()) + ]) + ->leftJoin('meetup_events', function ($join) { + $join->on('meetups.id', '=', 'meetup_events.meetup_id') + ->where('meetup_events.start', '>=', now()); + }) + ->selectRaw('meetups.*, MIN(meetup_events.start) as next_event_start') + ->groupBy('meetups.id') ->whereHas('city.country', fn($query) => $query->where('countries.code', $this->country)) ->when($this->search, fn($query) - => $query->where('name', 'ilike', '%'.$this->search.'%'), - ) - ->when($this->sortBy === 'city', - fn($query) - => $query - ->orderBy('cities.name', $this->sortDirection) - ->join('cities', 'meetups.city_id', '=', 'cities.id'), - fn($query) => $query->orderBy($this->sortBy, $this->sortDirection), + => $query->where('meetups.name', 'ilike', '%'.$this->search.'%'), ) + ->orderByDesc('has_future_events') + ->orderByRaw('next_event_start ASC NULLS LAST') ->paginate(15), ]; } @@ -67,8 +59,7 @@ new class extends Component { - {{ __('Name') }} + {{ __('Name') }} {{ __('Nächster Termin') }} {{ __('Links') }}