コード例 #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']);
         });
     });
 }
コード例 #2
0
 /**
  * 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');
         });
     });
 }
コード例 #3
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');
         });
     });
 }