/**
  * Returns a new table of all stocks of the specified inventory item.
  *
  * @param Inventory $item
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table(Inventory $item)
 {
     $stocks = $item->stocks();
     return $this->table->of('inventory.stocks', function (TableGrid $table) use($item, $stocks) {
         $table->with($stocks);
         $table->attributes(['class' => 'table table-hover table-striped']);
         $table->column('quantity');
         $table->column('location', function (Column $column) use($item) {
             $column->value = function (InventoryStock $stock) use($item) {
                 $name = $stock->location->trail;
                 return link_to_route('maintenance.inventory.stocks.show', $name, [$item->getKey(), $stock->getKey()]);
             };
         });
         $table->column('last_movement', function (Column $column) {
             $column->value = function (InventoryStock $stock) {
                 return $stock->last_movement;
             };
         });
         $table->column('last_movement_by', function (Column $column) {
             $column->value = function (InventoryStock $stock) {
                 return $stock->last_movement_by;
             };
         });
     });
 }
예제 #2
0
 /**
  * Captures the Inventory models restored event
  * and cascades the restore to all of it's stocks.
  *
  * @param Inventory $model
  */
 public function restored(Inventory $model)
 {
     $stocks = $model->stocks()->onlyTrashed()->get();
     if (count($stocks) > 0) {
         foreach ($stocks as $stock) {
             $stock->restore();
         }
     }
 }
 /**
  * Returns a new table of stocks for the specified inventory
  * item for work order part selection.
  *
  * @param WorkOrder $workOrder
  * @param Inventory $item
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table(WorkOrder $workOrder, Inventory $item)
 {
     $stocks = $item->stocks();
     return $this->table->of('work-orders.parts.stocks', function (TableGrid $table) use($workOrder, $item, $stocks) {
         $table->with($stocks)->paginate($this->perPage);
         $table->column('location', function (Column $column) use($item) {
             $column->value = function (InventoryStock $stock) use($item) {
                 $name = $stock->location->trail;
                 return link_to_route('maintenance.inventory.stocks.show', $name, [$item->getKey(), $stock->getKey()]);
             };
         });
         $table->column('quantity');
         $table->column('select', function (Column $column) use($workOrder, $item) {
             $column->value = function (InventoryStock $stock) use($workOrder, $item) {
                 $route = 'maintenance.work-orders.parts.stocks.take';
                 $params = [$workOrder->getKey(), $item->getKey(), $stock->getKey()];
                 $attributes = ['class' => 'btn btn-default btn-sm'];
                 return link_to_route($route, 'Select', $params, $attributes);
             };
         });
     });
 }