validate([ 'newCityName' => ['required', 'string', 'max:255', 'unique:cities,name'], 'newCityCountryId' => ['required', 'exists:countries,id'], 'newCityLatitude' => ['required', 'numeric'], 'newCityLongitude' => ['required', 'numeric'], ]); $city = City::create([ 'name' => $validated['newCityName'], 'country_id' => $validated['newCityCountryId'], 'latitude' => $validated['newCityLatitude'], 'longitude' => $validated['newCityLongitude'], 'slug' => str($validated['newCityName'])->slug(), 'created_by' => auth()->id(), ]); $this->city_id = $city->id; $this->reset(['newCityName', 'newCityCountryId', 'newCityLatitude', 'newCityLongitude']); \Flux\Flux::modal('add-city')->close(); } public function mount(): void { $this->meetup->load('media'); // Basic Information $this->name = $this->meetup->name ?? ''; $this->city_id = $this->meetup->city_id; $this->slug = $this->meetup->slug ?? ''; $this->intro = $this->meetup->intro; // Links and Social Media $this->telegram_link = $this->meetup->telegram_link; $this->webpage = $this->meetup->webpage; $this->twitter_username = $this->meetup->twitter_username; $this->matrix_group = $this->meetup->matrix_group; $this->nostr = $this->meetup->nostr; $this->nostr_status = $this->meetup->nostr_status; $this->simplex = $this->meetup->simplex; $this->signal = $this->meetup->signal; // Additional Information $this->community = $this->meetup->community; $this->github_data = $this->meetup->github_data ? json_encode($this->meetup->github_data, JSON_PRETTY_PRINT) : null; $this->visible_on_map = (bool) $this->meetup->visible_on_map; // System fields $this->created_by = $this->meetup->created_by; $this->created_at = $this->meetup->created_at?->format('Y-m-d H:i:s'); $this->updated_at = $this->meetup->updated_at?->format('Y-m-d H:i:s'); } public function updateMeetup(): void { $validated = $this->validate([ 'name' => ['required', 'string', 'max:255', Rule::unique('meetups')->ignore($this->meetup->id)], 'city_id' => ['nullable', 'exists:cities,id'], 'intro' => ['nullable', 'string'], 'telegram_link' => ['nullable', 'url', 'max:255'], 'webpage' => ['nullable', 'url', 'max:255'], 'twitter_username' => ['nullable', 'string', 'max:255'], 'matrix_group' => ['nullable', 'string', 'max:255'], 'nostr' => ['nullable', 'string', 'max:255'], 'simplex' => ['nullable', 'string', 'max:255'], 'signal' => ['nullable', 'string', 'max:255'], 'community' => ['required', 'string', 'max:255'], ]); // Convert github_data string back to array if provided if (!empty($validated['github_data'])) { $decoded = json_decode($validated['github_data'], true); if (json_last_error() === JSON_ERROR_NONE) { $validated['github_data'] = $decoded; } else { $validated['github_data'] = null; } } else { $validated['github_data'] = null; } $this->meetup->update($validated); if ($this->logo) { $this->meetup->clearMediaCollection('logo'); $this->meetup ->addMedia($this->logo->getRealPath()) ->usingName($this->meetup->name) ->toMediaCollection('logo'); $this->logo = null; $this->meetup->load('media'); } $this->dispatch('meetup-updated', name: $this->meetup->name); session()->flash('status', __('Meetup erfolgreich aktualisiert!')); } public function with(): array { return [ 'cities' => City::query() ->with([ 'country', ]) ->orderBy('name') ->get(), 'countries' => Country::query()->orderBy('countries.name')->get(), ]; } }; ?>