exists) { $this->post = $post; $this->title = $post->title; $this->body = $post->body; } } public function submitForm(): Redirector|RedirectResponse { $this->validate(); if (empty($this->post)) { Post::create($this->only('title', 'body')); } else { $this->post->update($this->only('title', 'body')); } session()->flash('message', 'Post successfully saved!'); return redirect()->route('posts.index'); } public function render(): View { return view('livewire.post-form'); } }