course->load('media'); // Basic Information $this->name = $this->course->name ?? ''; $this->lecturer_id = $this->course->lecturer_id; $this->description = $this->course->description; // System fields $this->created_by = $this->course->created_by; $this->created_at = $this->course->created_at?->format('Y-m-d H:i:s'); $this->updated_at = $this->course->updated_at?->format('Y-m-d H:i:s'); } public function updateCourse(): void { $validated = $this->validate([ 'name' => ['required', 'string', 'max:255'], 'lecturer_id' => ['required', 'exists:lecturers,id'], 'description' => ['nullable', 'string'], ]); $this->course->update($validated); if ($this->logo) { $this->course->clearMediaCollection('logo'); $this->course ->addMedia($this->logo->getRealPath()) ->usingName($this->course->name) ->toMediaCollection('logo'); $this->logo = null; $this->course->load('media'); } $this->dispatch('course-updated', name: $this->course->name); session()->flash('status', __('Kurs erfolgreich aktualisiert!')); } public function with(): array { return [ 'lecturers' => Lecturer::query()->orderBy('name')->get(), ]; } }; ?>