productId = $productId; $product = Product::findOrFail($productId); $this->sku = $product->sku; $this->name = $product->name; $this->description = $product->description ?? ''; $this->price = (string) $product->getRawOriginal('price') / 100; $this->active = $product->active; $this->resetValidation(); Flux::modal('edit-product')->show(); } public function save(): void { $this->validate([ 'sku' => 'required|string|max:50|unique:products,sku,' . $this->productId, 'name' => 'required|string|max:255', 'description' => 'nullable|string|max:1000', 'price' => 'required|numeric|min:0', 'active' => 'boolean', ]); $product = Product::findOrFail($this->productId); $product->update([ 'sku' => $this->sku, 'name' => $this->name, 'description' => $this->description ?: null, 'price' => $this->price, 'active' => $this->active, ]); $this->reset(); Flux::modal('edit-product')->close(); $this->dispatch('product-updated'); } }; ?>