Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $users = Users::get();
     $comments = Comments::get();
     $supports = Supports::get();
     $notes = Notes::get();
     $usersJson = array();
     $commentsJson = array();
     $supportsJson = array();
     $notesJson = array();
     // build users
     foreach ($users as $user) {
         array_push($usersJson, array('id' => $user->id, 'name' => $user->name));
     }
     // build comments
     foreach ($comments as $comment) {
         array_push($commentsJson, array('id' => $comment->id, 'article_id' => $comment->article_id, 'user_id' => $comment->user_id, 'comment' => $comment->comment, 'challenge' => $comment->challenge));
     }
     // build supports
     foreach ($supports as $support) {
         array_push($supportsJson, array('id' => $support->id, 'user_id' => $support->user_id, 'comment_id' => $support->comment_id));
     }
     // build notes
     foreach ($notes as $note) {
         array_push($notesJson, array('id' => $note->id, 'comment_id' => $note->comment_id, 'comment' => $note->comment));
     }
     // build json
     $json = array('users' => $usersJson, 'comments' => $commentsJson, 'supports' => $supportsJson, 'notes' => $notesJson);
     // display json
     echo json_encode($json);
 }
Ejemplo n.º 2
0
             } else {
                 echo 'error';
             }
         } else {
             echo 'Error, no has pasado ningún admin.';
         }
     } else {
         echo 'Error, no tienes permisos.';
     }
     break;
 case "get_notes":
     if ($_SESSION['user']['type'] == ADMIN || $_SESSION['user']['type'] == SUPERADMIN) {
         $note = new Notes($db);
         $filters = array();
         add_filter($filters, 'id_patient', $data['id']);
         $result = $note->get($filters);
         if ($result->resultado) {
             $encode = array();
             for ($i = 0; $i < count($result->datos); $i++) {
                 $encode[] = $result->datos[$i];
             }
             echo json_encode($encode);
         } else {
             echo 'vacio';
         }
     }
     break;
 case "insert_note":
     if ($_SESSION['user']['type'] == ADMIN || $_SESSION['user']['type'] == SUPERADMIN) {
         $note = new Notes($db);
         $data['note']['id_admin'] = $_SESSION['user']['id'];