public function Planes($action = null) { if (isset($action)) { if ($action == "create") { $data = Planes::firstOrCreate(Input::except("_token", "_user")); return $respuesta = array('Record' => $data, 'Result' => "OK"); } if ($action == "edit") { Planes::where("id", Input::get("id"))->update(Input::except("_token", "id", "_user")); return $respuesta = array('Record' => Planes::find(Input::get('id')), 'Result' => "OK"); } if ($action == "remove") { Planes::where('id', Input::get("id"))->delete(); return '{"Result":"OK"}'; } if ($action == "list") { $Records = Planes::get(); $respuesta = array('Records' => $Records, 'Result' => "OK"); return json_encode($respuesta); } if ($action == "empresas") { $nulos = DB::table('empresas')->select(DB::raw("'NO POSEE' as DisplayText, NULL as Value")); $respuesta = DB::table('empresas')->select("nombre as DisplayText", "id as Value")->union($nulos)->orderby('value', 'asc')->distinct()->get(); return "var opciones=" . json_encode($respuesta); } } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { // return 'entre al update'; $planes = Planes::find($id); if ($request->input('inactivo') != $planes->inactivo) { $planes->inactivo = $request->input('inactivo'); } else { $planes->plan = $request->input('plan'); $planes->idcarrera = $request->input('idcarrera'); $planes->inactivo = $request->input('inactivo'); } $planes->save(); return \Redirect::route('planes.index'); }