app/Jobs/WorkOrder/Part/Take.php
public function handle()
    {
        $quantity = $this->request->input('quantity');

        $reason = link_to_route('maintenance.work-orders.show', 'Used for Work Order', [$this->workOrder->getKey()]);

        $this->stock->take($quantity, $reason);

        // We'll check if the work order currently has the stock already attached.
        $stock = $this->workOrder->parts()->find($this->stock->getKey());

        if ($stock instanceof InventoryStock) {
            // Add on the quantity inputted to the existing record quantity.
            $newQuantity = $stock->pivot->quantity + $quantity;

            $this->workOrder->parts()->updateExistingPivot($stock->getKey(), ['quantity' => $newQuantity]);

            return true;
        }

        // It looks like the part isn't yet attached to
        // the work order. We'll attach it now.
        $this->workOrder->parts()->attach($this->stock->getKey(), compact('quantity'));

        return true;
    }
public function handle()
    {
        $quantity = $this->request->input('quantity');

        $reason = link_to_route('maintenance.work-orders.show', 'Used for Work Order', [$this->workOrder->getKey()]);

        $this->stock->take($quantity, $reason);

        // We'll check if the work order currently has the stock already attached.
        $stock = $this->workOrder->parts()->find($this->stock->getKey());

        if ($stock instanceof InventoryStock) {
            // Add on the quantity inputted to the existing record quantity.
            $newQuantity = $stock->pivot->quantity + $quantity;

            $this->workOrder->parts()->updateExistingPivot($stock->getKey(), ['quantity' => $newQuantity]);

            return true;
        }

        // It looks like the part isn't yet attached to
        // the work order. We'll attach it now.
        $this->workOrder->parts()->attach($this->stock->getKey(), compact('quantity'));

        return true;
    }
Execute the job.

@return bool