/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['tipo' => 'required']);
     $tipoInsumo = \App\TipoInsumo::find($id);
     $tipoInsumo->tipo = $request->input('tipo');
     $tipoInsumo->save();
     $request->session()->flash('msj_success', 'Se ha actualizado el insumo: ' . $request->input('tipo'));
     return redirect()->route('tipo-insumo.index');
 }
 public function getFiltrartipoinsumo(Request $request)
 {
     if (!$request->ajax()) {
         abort(403);
     }
     $datos = array();
     $inputs = $request->all();
     if (empty($inputs['search'])) {
         $tipoInsumos = \App\TipoInsumo::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id', 'tipo')->where('id', '>', 0)->take($inputs['limit'])->skip($inputs['offset'])->orderBy('tipo', 'ASC')->get();
     } else {
         $tipoInsumos = \App\TipoInsumo::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id', 'tipo')->where('tipo', 'LIKE', '%' . $inputs["search"] . '%')->take($inputs['limit'])->skip($inputs['offset'])->orderBy('tipo', 'ASC')->get();
     }
     $cantidad = \DB::select(\DB::raw("SELECT FOUND_ROWS() AS total;"));
     $cantidad = $cantidad[0]->total;
     $n = 1;
     foreach ($tipoInsumos as $tipoInsumo) {
         $url = '<a href="' . route('tipo-insumo.edit', $tipoInsumo->id) . '" class="btn btn-xs btn-success"><i class="fa fa-btn fa-edit"></i>Editar</a>';
         $datos[] = ['num' => $n++, 'insumo' => $tipoInsumo->tipo, 'act' => $url];
     }
     return \Response::json(['total' => $cantidad, 'rows' => $datos]);
 }