'Barang', 'inventory' => Inventory::with(['user', 'user.biography'])->barbershop()->latest()->get(), ]); } public function store(InventoryRequest $request): RedirectResponse { $validatedData = $request->validated(); DB::transaction(function () use ($validatedData) { $newInventory = Inventory::create(array_merge($validatedData, [ 'user_id' => Auth::id(), 'barbershop_id' => Auth::user()->barbershop_id, ])); $this->uploadAttachment($validatedData['image'], 'inventory', Inventory::class, $newInventory->id); }); notify()->success('Data berhasil ditambahkan', 'Berhasil'); return back(); } public function update(Inventory $inventory, InventoryRequest $request): RedirectResponse { $validatedData = $request->validated(); DB::transaction(function () use ($inventory, $validatedData) { $inventory->update($validatedData); if (isset($validatedData['image'])) { $this->uploadAttachment($validatedData['image'], 'inventory', Inventory::class, $inventory->id); } }); notify()->success('Data berhasil diubah', 'Berhasil'); return back(); } public function delete(Inventory $inventory): RedirectResponse { DB::transaction(function () use ($inventory) { $this->deleteAttachment('inventory', $inventory); $inventory->delete(); }); notify()->success('Data berhasil dihapus', 'Berhasil'); return back(); } }