Ejemplo n.º 1
0
 /**
  * Returns a new form for the specified asset.
  *
  * @param Asset $asset
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function form(Asset $asset)
 {
     return $this->form->of('assets', function (FormGrid $form) use($asset) {
         if ($asset->exists) {
             $method = 'PATCH';
             $route = route('maintenance.assets.update', [$asset->getKey()]);
             $form->submit = 'Save';
         } else {
             $method = 'POST';
             $route = route('maintenance.assets.store');
             $form->submit = 'Create';
         }
         $categories = Category::getSelectHierarchy('assets');
         $locations = Location::getSelectHierarchy();
         $form->resource($this, $route, $asset, compact('method'));
         $form->fieldset(function (Fieldset $fieldset) use($categories, $locations) {
             $fieldset->control('input:text', 'tag')->attributes(['placeholder' => 'ex. 100010']);
             $fieldset->control('input:text', 'name')->attributes(['placeholder' => 'ex. Ford F150']);
             $fieldset->control('select', 'category')->options($categories)->value(function (Asset $asset) {
                 return $asset->category_id;
             });
             $fieldset->control('select', 'location')->options($locations)->value(function (Asset $asset) {
                 return $asset->location_id;
             });
             $fieldset->control('input:textarea', 'description');
             $fieldset->control('select', 'condition')->options(trans('assets.conditions'))->value(function (Asset $asset) {
                 return $asset->condition_number;
             });
             $fieldset->control('input:text', 'vendor')->attributes(['placeholder' => 'ex. Ford']);
             $fieldset->control('input:text', 'make')->attributes(['placeholder' => 'ex. F']);
             $fieldset->control('input:text', 'model')->attributes(['placeholder' => 'ex. 150']);
             $fieldset->control('input:text', 'serial')->attributes(['placeholder' => 'ex. 153423-13432432-2342423']);
             $fieldset->control('input:text', 'size')->attributes(['placeholder' => 'ex. 1905 x 2463']);
             $fieldset->control('input:text', 'weight')->attributes(['placeholder' => 'ex. 1 Ton']);
             $fieldset->control('input:text', 'acquired_at')->attributes(['class' => 'pickadate', 'placeholder' => 'Click to Select a Date']);
             $fieldset->control('input:text', 'end_of_life')->attributes(['class' => 'pickadate', 'placeholder' => 'Click to Select a Date']);
         });
     });
 }
Ejemplo n.º 2
0
 /**
  * Returns a new form for work orders.
  *
  * @param WorkOrder $workOrder
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function form(WorkOrder $workOrder)
 {
     return $this->form->of('work-orders', function (FormGrid $form) use($workOrder) {
         if ($workOrder->exists) {
             $method = 'PATCH';
             $url = route('maintenance.work-orders.update', [$workOrder->getKey()]);
             $form->submit = 'Save';
         } else {
             $method = 'POST';
             $url = route('maintenance.work-orders.store');
             $form->submit = 'Create';
         }
         $form->with($workOrder);
         $form->attributes(compact('method', 'url'));
         $form->fieldset(function (Fieldset $fieldset) {
             $fieldset->control('select', 'category')->value(function (WorkOrder $workOrder) {
                 return $workOrder->category_id;
             })->options(function () {
                 return Category::getSelectHierarchy('work-orders');
             });
             $fieldset->control('select', 'location')->value(function (WorkOrder $workOrder) {
                 return $workOrder->location_id;
             })->options(function () {
                 return Location::getSelectHierarchy();
             });
             $fieldset->control('select', 'status')->options(function () {
                 $statuses = Status::all()->pluck('name', 'id');
                 $statuses[0] = 'None';
                 return $statuses;
             });
             $fieldset->control('select', 'priority')->value(function (WorkOrder $workOrder) {
                 return $workOrder->priority_id;
             })->options(function () {
                 $priorities = Priority::all()->pluck('name', 'id');
                 $priorities[0] = 'None';
                 return $priorities;
             });
             $fieldset->control('select', 'assets[]')->label('Assets')->options(function () {
                 return Asset::all()->pluck('name', 'id');
             })->attributes(['class' => 'select2', 'multiple' => true]);
             $fieldset->control('input:text', 'subject')->attributes(['placeholder' => 'ex. Worked on HVAC']);
             $fieldset->control('input:textarea', 'description');
         });
     });
 }
 /**
  * Returns a new form of the specified inventory stock.
  *
  * @param Inventory      $item
  * @param InventoryStock $stock
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function form(Inventory $item, InventoryStock $stock)
 {
     return $this->form->of('inventory.stocks', function (FormGrid $form) use($item, $stock) {
         if ($stock->exists) {
             $method = 'PATCH';
             $url = route('maintenance.inventory.stocks.update', [$item->getKey(), $stock->getKey()]);
             $form->submit = 'Save';
         } else {
             $method = 'POST';
             $url = route('maintenance.inventory.stocks.store', [$item->getKey()]);
             $form->submit = 'Create';
         }
         $locations = Location::getSelectHierarchy();
         $form->with($stock);
         $form->attributes(compact('method', 'url'));
         $form->fieldset(function (Fieldset $fieldset) use($locations) {
             $fieldset->control('select', 'location')->value(function (InventoryStock $stock) {
                 return $stock->location_id;
             })->options($locations);
             $fieldset->control('input:text', 'quantity')->attributes(['placeholder' => 'ex. 45']);
             $fieldset->control('input:text', 'reason')->attributes(['placeholder' => 'ex. Stock Update']);
             $fieldset->control('input:text', 'cost')->attributes(['placeholder' => 'ex. 15.00']);
         });
     });
 }