public function get_records()
 {
     $paginator = RegisterRecord::where('doctor_id', Session::get('doctor.id'))->where('created_at', 'like', Input::get('date', date('Y-m-d')) . '%')->with('user')->paginate($this->default_num_per_page);
     $result = array();
     $records = $paginator->getCollection();
     foreach ($records as $record) {
         $user = $record->user;
         $result[] = array('record_id' => $record->id, 'user_name' => $user->real_name);
     }
     return Response::json(array('error_code' => 0, 'records' => $result, 'last_page' => $paginator->getLastPage()));
 }
 public function get_records_html()
 {
     $records = RegisterRecord::where('user_id', Session::get('user.id'))->with('doctor')->get();
     foreach ($records as $record) {
         $doctor = $record->doctor;
         $period = $record->period()->first();
         $schedule = Schedule::find($period['schedule_id']);
         $schedule_info = array('date' => $schedule->date, 'period' => $this->possible_period[$schedule->period], 'start' => date('H:i', strtotime($period->start)), 'end' => date('H:i', strtotime($period->end)));
         $data[] = array('id' => $record->id, 'status' => $this->possible_status[$record->status], 'can_be_canceled' => $record->status == 0, 'created_at' => $record->created_at->format('Y-m-d H:i'), 'start' => $record->status ? date('Y-m-d H:i', strtotime($record->start)) : '', 'schedule' => $schedule_info, 'department' => $doctor->department->name, 'doctor' => array('id' => $doctor->id, 'name' => $doctor->name, 'title' => $doctor->title));
     }
     return View::make('user.record', array('records' => $data));
 }