/** * Processes creating a variant of the specified * inventory item. * * @param VariantRequest $request * @param int|string $inventoryId * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function store(VariantRequest $request, $inventoryId) { $variant = $this->inventory->createVariant($request, $inventoryId); if ($variant) { $message = sprintf('Successfully created item variant: %s', link_to_route('maintenance.inventory.show', 'Show', [$variant->id])); return redirect()->route('maintenance.inventory.show', [$inventoryId, '#tab-variants'])->withSuccess($message); } else { $message = 'There was an error creating a variant of this item. Please try again.'; return redirect()->route('maintenance.inventory.show', [$inventoryId])->withErrors($message); } }