Exemple #1
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     $this->metric->user_id = auth()->id();
     $this->metric->name = $this->request->input('name');
     $this->metric->symbol = $this->request->input('symbol');
     return $this->metric->save();
 }
 public function run()
 {
     DB::table('locations')->delete();
     //Create Location
     $location = new Location();
     $location->name = 'Nonlocated';
     $location->save();
     $location = new Location();
     $location->name = 'Tools';
     $location->save();
     DB::table('metrics')->delete();
     $metric = new Metric();
     $metric->name = "Stk";
     $metric->symbol = "stk";
     $metric->save();
 }
 /**
  * Returns a new form for the specified metric.
  *
  * @param Metric $metric
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function form(Metric $metric)
 {
     return $this->form->of('metrics', function (FormGrid $form) use($metric) {
         if ($metric->exists) {
             $method = 'PATCH';
             $url = route('maintenance.metrics.update', [$metric->getKey()]);
             $form->submit = 'Save';
         } else {
             $method = 'POST';
             $url = route('maintenance.metrics.store');
             $form->submit = 'Create';
         }
         $form->attributes(compact('method', 'url'));
         $form->with($metric);
         $form->fieldset(function (Fieldset $fieldset) {
             $fieldset->control('input:text', 'name')->attributes(['placeholder' => 'ex. Tonnes, Pounds, Grams']);
             $fieldset->control('input:text', 'symbol')->attributes(['placeholder' => 'ex. T, LBS, G']);
         });
     });
 }
 /**
  * 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');
         });
     });
 }
Exemple #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the patient
     $metric = Metric::find($id);
     $metric->delete();
     // redirect
     return redirect()->to('metric.index')->with('message', trans('messages.metric-succesfully-deleted'));
 }
Exemple #6
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     $this->metric->name = $this->request->input('name', $this->metric->name);
     $this->metric->symbol = $this->request->input('symbol', $this->metric->symbol);
     return $this->metric->save();
 }
 /**
  * Deletes the specified metric.
  *
  * @param int|string $id
  *
  * @return bool
  */
 public function destroy($id)
 {
     $metric = $this->metric->findOrFail($id);
     return $metric->delete();
 }
Exemple #8
0
 /**
  * @return \Illuminate\Routing\Route|null|string
  */
 public function ingnoreId()
 {
     $id = $this->route('metric');
     $name = $this->input('name');
     return Metric::where(compact('id', 'name'))->exists() ? $id : '';
 }