script)) { $this->fill([ 'name' => $this->script->name, 'path' => $this->script->path, 'content' => $this->script->content, ]); } } #[On('edit-script')] public function loadScript($id) { $this->script = auth()->user()->scripts()->find($id); $this->fill([ 'name' => $this->script->name, 'path' => $this->script->path, 'content' => $this->script->content, ]); } public function resetToNew() { $this->script = null; $this->reset(['name', 'path', 'content']); } public function create() { $this->validate(); if (empty($this->script)) { auth()->user()->scripts()->create([ 'name' => $this->name, 'path' => str($this->path)->remove('.sh')->lower()->kebab()->toString(), 'content' => $this->content ]); } else { $this->script->update([ 'name' => $this->name, 'path' => str($this->path)->remove('.sh')->lower()->kebab()->toString(), 'content' => $this->content ]); $this->script->refresh(); } $this->reset(['name', 'path', 'content']); } public function render() { return view('livewire.forms.script'); } }