lecturer->load('media'); $this->name = $this->lecturer->name ?? ''; $this->subtitle = $this->lecturer->subtitle; $this->intro = $this->lecturer->intro; $this->description = $this->lecturer->description; $this->active = (bool) $this->lecturer->active; $this->website = $this->lecturer->website; $this->twitter_username = $this->lecturer->twitter_username; $this->nostr = $this->lecturer->nostr; $this->lightning_address = $this->lecturer->lightning_address; $this->lnurl = $this->lecturer->lnurl; $this->node_id = $this->lecturer->node_id; $this->paynym = $this->lecturer->paynym; $this->created_by = $this->lecturer->created_by; $this->created_at = $this->lecturer->created_at?->format('Y-m-d H:i:s'); $this->updated_at = $this->lecturer->updated_at?->format('Y-m-d H:i:s'); } public function updateLecturer(): void { $validated = $this->validate([ 'name' => ['required', 'string', 'max:255', Rule::unique('lecturers')->ignore($this->lecturer->id)], 'subtitle' => ['nullable', 'string'], 'intro' => ['nullable', 'string'], 'description' => ['nullable', 'string'], 'active' => ['boolean'], 'website' => ['nullable', 'url', 'max:255'], 'twitter_username' => ['nullable', 'string', 'max:255'], 'nostr' => ['nullable', 'string', 'max:255'], 'lightning_address' => ['nullable', 'string'], 'lnurl' => ['nullable', 'string'], 'node_id' => ['nullable', 'string', 'max:255'], 'paynym' => ['nullable', 'string'], ]); $this->lecturer->update($validated); if ($this->avatar) { $this->lecturer->clearMediaCollection('avatar'); $this->lecturer ->addMedia($this->avatar->getRealPath()) ->usingName($this->lecturer->name) ->toMediaCollection('avatar'); $this->avatar = null; $this->lecturer->load('media'); } $this->dispatch('lecturer-updated', name: $this->lecturer->name); session()->flash('status', __('Dozent erfolgreich aktualisiert!')); } }; ?>