/** * Execute the job. * * @return bool */ public function handle() { $this->stock->user_id = auth()->id(); $this->stock->inventory_id = $this->inventory->getKey(); $this->stock->location_id = $this->request->input('location'); $this->stock->quantity = $this->request->input('quantity'); $this->stock->cost = $this->request->input('cost'); $this->stock->reason = $this->request->input('reason'); return $this->stock->save(); }
/** * Returns a new form for creating a new inventory item. * * @param Inventory $inventory * @param bool|false $variant * * @return \Orchestra\Contracts\Html\Builder */ public function form(Inventory $inventory, $variant = false) { return $this->form->of('inventory', function (FormGrid $form) use($inventory, $variant) { if ($inventory->exists) { if ($variant === true) { // If the inventory item exists and we're looking to create a form // for a variant, we'll set the forms options accordingly. $method = 'POST'; $url = route('maintenance.inventory.variants.store', [$inventory->getKey()]); $form->submit = 'Create'; } else { // Otherwise we'll set the options to update the specified inventory item. $method = 'PATCH'; $url = route('maintenance.inventory.update', [$inventory->getKey()]); $form->submit = 'Save'; } } else { $method = 'POST'; $url = route('maintenance.inventory.store'); $form->submit = 'Create'; } $form->with($inventory); $form->attributes(compact('method', 'url')); $categories = Category::getSelectHierarchy('inventories'); $metrics = Metric::all()->pluck('name', 'id'); $metrics->put(0, 'None'); $form->fieldset(function (Fieldset $fieldset) use($categories, $metrics) { $fieldset->control('select', 'category')->value(function (Inventory $item) { return $item->category_id; })->options($categories); $fieldset->control('select', 'metric')->value(function (Inventory $item) { return $item->metric_id; })->options($metrics); $fieldset->control('input:text', 'name')->attributes(['placeholder' => 'ex. Nails']); $fieldset->control('input:textarea', 'description'); }); }); }
/** * Returns a new navbar for the inventory stock index. * * @param Inventory $item * * @return \Illuminate\Support\Fluent */ public function navbar(Inventory $item) { return $this->fluent(['id' => 'inventory-stocks', 'title' => 'Item Stocks', 'url' => route('maintenance.inventory.stocks.index', [$item->getKey()]), 'menu' => view('inventory.stocks._nav', compact('item')), 'attributes' => ['class' => 'navbar-default']]); }
/** * Returns a new form for putting the stock from the * specified work order back into inventory. * * @param WorkOrder $workOrder * @param Inventory $inventory * @param InventoryStock $stock * * @return \Orchestra\Contracts\Html\Builder */ public function formPut(WorkOrder $workOrder, Inventory $inventory, InventoryStock $stock) { return $this->form->of('work-orders.parts.stocks.put', function (FormGrid $form) use($workOrder, $inventory, $stock) { $form->attributes(['method' => 'POST', 'url' => route('maintenance.work-orders.parts.stocks.put', [$workOrder->getKey(), $inventory->getKey(), $stock->getKey()])]); $form->submit = 'Save'; $form->fieldset(function (Fieldset $fieldset) use($inventory, $stock) { $metric = $inventory->getMetricSymbol(); $fieldset->control('input:text', 'quantity', function (Field $field) { $field->label = 'Return Quantity'; })->value($stock->pivot->quantity)->attribute(['placeholder' => "Enter Quantity in {$metric}"]); }); }); }