/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $machine = Machine::findOrFail($id);
     $machine->delete();
     return redirect('machines');
 }
 /**
  * Metodo para hacer la busqueda
  */
 public static function search(Request $request)
 {
     $items = array();
     $search = '';
     if ($request->input('search')) {
         $search = $request->input('search');
         $arrparam = explode(' ', $search);
         $items = Machine::whereNested(function ($q) use($arrparam) {
             $p = $arrparam[0];
             $q->whereNested(function ($q) use($p) {
                 $q->where('id', 'LIKE', '%' . $p . '%');
                 $q->orwhere('name', 'LIKE', '%' . $p . '%');
                 $q->orwhere('reference', 'LIKE', '%' . $p . '%');
                 $q->orwhere('variables', 'LIKE', '%' . $p . '%');
                 $q->orwhere('use_common', 'LIKE', '%' . $p . '%');
                 $q->orwhere('enable', 'LIKE', '%' . $p . '%');
             });
             $c = count($arrparam);
             if ($c > 1) {
                 for ($i = 1; $i < $c; $i++) {
                     $p = $arrparam[$i];
                     $q->whereNested(function ($q) use($p) {
                         $q->where('id', 'LIKE', '%' . $p . '%');
                         $q->orwhere('name', 'LIKE', '%' . $p . '%');
                         $q->orwhere('reference', 'LIKE', '%' . $p . '%');
                         $q->orwhere('variables', 'LIKE', '%' . $p . '%');
                         $q->orwhere('use_common', 'LIKE', '%' . $p . '%');
                         $q->orwhere('enable', 'LIKE', '%' . $p . '%');
                     }, 'OR');
                 }
             }
         })->whereNull('deleted_at')->orderBy('name', 'ASC')->paginate(10);
         return View::make('admin.machine.view_machine', compact('items', 'search'));
     }
 }
示例#3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit(AddMachineRequest $request, $id)
 {
     $machine = Machine::findOrFail($id);
     $machine->update($request->all());
     return view('machines.machines_create');
 }
 public function machineJson()
 {
     $machines = Machine::all();
     return \Response::json($machines);
 }