Site::orderBy('name')->get(), ]); } public function create(): void { $this->resetForm(); $this->showForm = true; } public function edit(int $id): void { $site = Site::findOrFail($id); $this->editingId = $site->id; $this->name = $site->name; $this->url = $site->url; $this->description = $site->description; $this->showForm = true; } public function save(): void { $validated = $this->validate([ 'name' => ['required', 'string', 'max:255'], 'url' => ['required', 'string', 'max:255'], 'description' => ['nullable', 'string'], ]); Site::updateOrCreate(['id' => $this->editingId], $validated); $this->resetForm(); $this->showForm = false; } public function delete(int $id): void { Site::findOrFail($id)->delete(); } public function resetForm(): void { $this->editingId = null; $this->name = ''; $this->url = ''; $this->description = null; $this->resetValidation(); } }