/** * Creates a variant of the specified inventory item. * * @param InventoryRequest $request * @param int|string $itemId * * @return bool */ public function store(InventoryRequest $request, $itemId) { $item = $this->inventory->findOrFail($itemId); $variant = $item->newVariant(); $variant->name = $request->input('name', $item->name); $variant->category_id = $request->input('category', $item->category_id); $variant->metric_id = $request->input('metric', $item->metric_id); return $variant->save(); }
/** * Processes returning stock from the work order back into the specified inventory. * * @param PartReturnRequest $request * @param int|string $workOrderId * @param int|string $itemId * @param int|string $stockId * * @throws \Stevebauman\Inventory\Exceptions\InvalidQuantityException * * @return bool */ public function postPut(PartReturnRequest $request, $workOrderId, $itemId, $stockId) { $workOrder = $this->workOrder->findOrFail($workOrderId); // Even though the inventory item isn't necessary here, we'll // find it anyway so we can check for the requests validity // and ensure the specified stock is actually attached to // the one requested. $item = $this->inventory->findOrFail($itemId); $item->stocks()->findOrFail($stockId); $stock = $workOrder->parts()->findOrFail($stockId); return $this->dispatch(new Put($request, $workOrder, $stock)); }
/** * Deletes the specified inventory item. * * @param int|string $id * * @return bool */ public function destroy($id) { $item = $this->inventory->findOrFail($id); return $item->delete(); }
/** * Regenerates the SKU of the specified inventory item. * * @param int|string $id * * @return bool */ public function regenerate($id) { $item = $this->inventory->findOrFail($id); return $item->regenerateSku(); }
/** * Deletes the specified inventory stock. * * @param int|string $itemId * @param int|string $stockId * * @return bool */ public function destroy($itemId, $stockId) { $item = $this->inventory->findOrFail($itemId); $stock = $item->stocks()->findOrFail($stockId); return $stock->delete(); }