Ejemplo n.º 1
0
 public function index($type = 'driver')
 {
     $this->db->where('type', $type);
     $users = array();
     $result = $this->db->get('users')->result();
     foreach ($result as $user) {
         array_push($users, User_model::initialize($user)->asJson());
     }
     $this->output->set_content_type('application/json')->set_status_header(200)->set_output(json_encode(array('users' => $users)));
 }
Ejemplo n.º 2
0
 public function show($timing_id)
 {
     $this->authenticate();
     $row = $this->db->where('id', $timing_id)->get('timings')->row();
     if ($row == NULL) {
         $this->output->set_status_header(404)->set_output(json_encode(array('code' => 404, 'message' => 'Timing not found with given ID')));
         $this->output->_display();
         exit;
     }
     $timing = Timing_model::initialize($row);
     $result = $this->db->join('student_timings', 'student_timings.student_id = users.id', 'INNER')->where('student_timings.timing_id', $timing->id)->get('users')->result();
     $students = array();
     foreach ($result as $row) {
         $students[] = User_model::initialize($row)->asJsonStudent();
     }
     $output = $timing->asJson();
     $output['students'] = $students;
     $this->output->set_status_header(200)->set_output(json_encode($output));
 }
Ejemplo n.º 3
0
 public function driver()
 {
     $this->db->from('users')->select('users.*');
     $this->db->join('driver_routes', 'driver_routes.user_id = users.id', 'inner');
     $this->db->where('driver_routes.route_id = ' . $this->id);
     $user = $this->db->get()->row();
     if ($user != null) {
         $this->driver = User_model::initialize($user);
     }
     return $this->driver;
 }
 public function getDriver()
 {
     $row = $this->db->join('driver_timings', 'driver_timings.driver_id = users.id', 'INNER')->where('driver_timings.timing_id', $this->id)->get('users')->row();
     if ($row == NULL) {
         return NULL;
     }
     $driver = User_model::initialize($row);
     return $driver->asJson();
 }
 public function asJson()
 {
     $row = $this->db->where('id', $this->user_id)->get('users')->row();
     $user = User_model::initialize($row);
     return array('id' => $this->id, 'token' => $this->token, 'device_id' => $this->device_id, 'user' => $user->routeAsJson());
 }