public function postCambiarestado()
 {
     if (Request::ajax()) {
         //$eventoid = Input::get('id');
         $eventos = Eventos::find(Input::get('id'));
         $eventos['estado'] = Input::get('estado');
         $tipotabla = Input::get('tipotabla');
         $eventos['usuario_updated_at'] = Auth::user()->id;
         // $eventos->save();
         if ($tipotabla == '1') {
             DB::table('evento_consulta')->where('id', Input::get('id'))->update(array('estado' => $eventos['estado'], 'usuario_updated_at' => $eventos['usuario_updated_at'], 'updated_at' => date('Y-m-d H:i:s')));
         }
         if ($tipotabla == '2') {
             DB::table('evento_metodo')->where('id', Input::get('id'))->update(array('estado' => $eventos['estado'], 'usuario_updated_at' => $eventos['usuario_updated_at'], 'updated_at' => date('Y-m-d H:i:s')));
         }
         return Response::json(array('rst' => 1, 'msj' => 'Registro actualizado correctamente'));
     }
 }
 public function Calendar($action)
 {
     if (isset($action)) {
         if ($action == "create") {
             $evento = Eventos::firstOrCreate(Input::all());
             foreach ($evento->areas() as $area) {
                 $evento->area .= $area->nombre . ",";
             }
             return $respuesta = array('Record' => $evento, 'Result' => "OK");
         }
         if ($action == "edit") {
             $evento = Eventos::find(Input::get("id"));
             $evento->fill(Input::all());
             $evento->save();
             foreach ($evento->areas() as $area) {
                 $evento->area .= $area->nombre . ",";
             }
             return $respuesta = array('Record' => $evento, 'Result' => "OK");
         }
         if ($action == "remove") {
             Eventos::where('id', Input::get("id"))->delete();
             return '{"Result":"OK"}';
         }
         if ($action == "list") {
             $Records = Eventos::get();
             $Records->each(function ($evento) {
                 foreach ($evento->areas() as $area) {
                     $evento->area .= $area->nombre . ",";
                 }
             });
             $respuesta = array('Records' => $Records, 'Result' => "OK");
             return json_encode($respuesta);
         }
         if ($action == "areas") {
             $nulos = DB::table('areas')->select(DB::raw("'Ninguna' as DisplayText,'null' as value"));
             $respuesta = Areas::select("nombre as DisplayText", "id as Value")->union($nulos)->orderby('value', 'asc')->distinct()->get();
             return "var opciones=" . json_encode($respuesta);
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /eventos/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $evento = Eventos::find($id);
     if ($evento->user_id == Auth::user()->id || Auth::user()->admin) {
         $evento->delete();
         return Response::json(['status' => 'TRUE'], 200);
     } else {
         return Response::json(['status' => 'ERROR'], 403);
     }
 }