public function listAll($page = 1)
 {
     $toReturn = array();
     $toReturn['teachers'] = User::where('role', 'teacher')->where('activated', '1')->orderBy('id', 'DESC')->take('20')->skip(20 * ($page - 1))->get()->toArray();
     $toReturn['transports'] = transportation::get()->toArray();
     $toReturn['totalItems'] = User::where('role', 'teacher')->where('activated', '1')->count();
     $toReturn['userRole'] = $this->data['users']->role;
     $newrole = $this->data['users']->newrole;
     $newrole_array = json_decode($newrole);
     /*$params= permissions::where('moduleId',1)->where('permission',1)->get();
     			foreach ($params as $param) {
     		$uniparam[]=$param->roleId;
     }*/
     $uniparam = array(5, 8, 15);
     if ($toReturn['userRole'] == "teacher") {
         if (array_intersect($newrole_array, $uniparam)) {
             $toReturn['access'] = 1;
         } else {
             $toReturn['access'] = 0;
         }
     } elseif ($toReturn['userRole'] == "admin") {
         $toReturn['access'] = 1;
     } else {
         $toReturn['access'] = 0;
     }
     $toReturn['newuserRole'] = $this->data['users']->newrole;
     return $toReturn;
 }
 function edit($id)
 {
     if ($this->data['users']->role != "admin") {
         exit;
     }
     $transportation = transportation::find($id);
     $transportation->transportTitle = Input::get('transportTitle');
     $transportation->transportDescription = Input::get('transportDescription');
     $transportation->transportDriverContact = Input::get('transportDriverContact');
     $transportation->transportFare = Input::get('transportFare');
     $transportation->save();
     return $this->panelInit->apiOutput(true, $this->panelInit->language['editTransport'], $this->panelInit->language['transportUpdated'], $transportation->toArray());
 }
 public function listAll($page = 1)
 {
     $toReturn = array();
     if ($this->data['users']->role == "parent") {
         $studentId = array();
         $parentOf = json_decode($this->data['users']->parentOf, true);
         if (is_array($parentOf)) {
             while (list($key, $value) = each($parentOf)) {
                 $studentId[] = $value['id'];
             }
         }
         if (count($studentId) > 0) {
             $students = User::where('role', 'student')->where('activated', '1')->whereIn('id', $studentId)->orderBy('studentRollId', 'ASC')->take('20')->skip(20 * ($page - 1))->get()->toArray();
             $toReturn['totalItems'] = User::where('role', 'student')->whereIn('id', $studentId)->where('activated', '1')->count();
         } else {
             $students = array();
             $toReturn['totalItems'] = 0;
         }
     } elseif ($this->data['users']->role == "teacher") {
         $classesList = array();
         $classes = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->where('classTeacher', 'LIKE', '%"' . $this->data['users']->id . '"%')->get()->toArray();
         while (list(, $value) = each($classes)) {
             $classesList[] = $value['id'];
         }
         if (count($classesList) > 0) {
             $students = User::where('role', 'student')->whereIn('studentClass', $classesList)->where('activated', '1')->orderBy('studentRollId', 'ASC')->take('20')->skip(20 * ($page - 1))->get()->toArray();
             $toReturn['totalItems'] = User::where('role', 'student')->whereIn('studentClass', $classesList)->where('activated', '1')->count();
         } else {
             $students = array();
             $toReturn['totalItems'] = 0;
         }
     } else {
         $students = User::where('role', 'student')->where('activated', '1')->orderBy('studentRollId', 'ASC')->take('20')->skip(20 * ($page - 1))->get()->toArray();
         $toReturn['totalItems'] = User::where('role', 'student')->where('activated', '1')->count();
     }
     $toReturn['classes'] = $classes = classes::where('classAcademicYear', $this->panelInit->selectAcYear)->get()->toArray();
     $classArray = array();
     while (list(, $value) = each($classes)) {
         $classArray[$value['id']] = $value['className'];
     }
     $toReturn['transports'] = transportation::get()->toArray();
     $toReturn['userRole'] = $this->data['users']->role;
     $toReturn['students'] = array();
     while (list(, $student) = each($students)) {
         $toReturn['students'][] = array('id' => $student['id'], "studentRollId" => $student['studentRollId'], "fullName" => $student['fullName'], "username" => $student['username'], "email" => $student['email'], "isLeaderBoard" => $student['isLeaderBoard'], "studentClass" => isset($classArray[$student['studentClass']]) ? $classArray[$student['studentClass']] : "");
     }
     return $toReturn;
 }