/** * Show the form for editing the specified visitante. * * @param int $id * @return Response */ public function edit($id) { $visitante = Visitante::find($id); return View::make('visitantes.edit', compact('visitante')); }
public function visitantes($action) { if (isset($action)) { if ($action == "create") { $data = Visitante::firstOrCreate(Input::all()); return $respuesta = array('Record' => $data, 'Result' => "OK"); } if ($action == "edit") { Visitante::where("id", Input::get("id"))->update(Input::except("id")); return $respuesta = array('Record' => Visitante::find(Input::get('id')), 'Result' => "OK"); } if ($action == "remove") { Visitante::where('id', Input::get("id"))->delete(); return '{"Result":"OK"}'; } if ($action == "list") { $Records = Visitante::get(); $respuesta = array('Records' => $Records, 'Result' => "OK"); return json_encode($respuesta); } if ($action == "residencia") { $nulos = DB::table('residencias')->select(DB::raw("'NO POSEE' as DisplayText, NULL as Value")); $respuesta = Residencias::select("nombre as DisplayText", "id as Value")->union($nulos)->orderby('value', 'asc')->distinct()->get(); return "var opciones=" . json_encode($respuesta); } } }