Пример #1
0
 public function manageUsers()
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return Redirect::to('/');
     }
     $institutes = Institute::where('status', 'active')->orderBy('name')->get();
     if (isset($institutes) && count($institutes) > 0) {
         return View::make('admin.users')->with('institutesFound', true)->with('institutes', $institutes);
     } else {
         return View::make('admin.users')->with('institutesFound', false);
     }
 }
Пример #2
0
 public function listInstitutes($status, $page)
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     if (isset($status)) {
         $institutes = Institute::where('status', '=', $status)->with('location')->get();
         if (isset($institutes) && count($institutes) > 0) {
             return json_encode(array('message' => 'found', 'institutes' => $institutes->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
Пример #3
0
 public function getConnections($status = 'active', $page = 1)
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $connections = InstituteConnection::where('status', $status)->get();
     if (isset($connections) && count($connections) > 0) {
         $connectionArray = array();
         foreach ($connections as $connection) {
             $connectionFrom = Institute::where('id', $connection->connection_id)->first();
             $connectionTo = Institute::where('id', $connection->institute_id)->first();
             if (isset($connectionFrom) && isset($connectionTo)) {
                 $connectionArray[] = array('id' => $connection->id, 'connection_from' => $connectionFrom->name, 'connection_from_location' => $connectionFrom->city . ', ' . $connectionFrom->country, 'connection_to' => $connectionTo->name, 'connection_to_location' => $connectionTo->city . ', ' . $connectionTo->country);
             }
         }
         return json_encode(array('message' => 'found', 'connections' => $connectionArray));
     } else {
         return json_encode(array('message' => 'empty'));
     }
 }
Пример #4
0
 public function institutes()
 {
     $key = Input::get('keyword');
     $city = Input::get('city');
     $cityId = Input::get('c');
     // city id
     if (isset($key)) {
         if (isset($cityId) && strlen($cityId) > 0) {
             $institutes = Institute::where('name', 'like', '%' . $key . '%')->where('location_id', '=', $cityId)->with('location')->get();
         } else {
             $institutes = Institute::where('name', 'like', '%' . $key . '%')->with('location')->get();
         }
         $city = str_replace("-", " / ", $city);
         if (isset($institutes) && count($institutes) > 0) {
             return View::make('institute.institutes')->with('institutes', $institutes)->with('city', $city)->with('status', 'search');
         } else {
             return View::make('institute.institutes')->with('city', $city)->with('status', 'search');
         }
     } else {
         return View::make('institute.institutes')->with('city', '')->with('status', 'direct');
     }
 }
Пример #5
0
 public function searchByKeyword($key, $cityId = null)
 {
     if (isset($key)) {
         if (isset($cityId)) {
             $experts = Expert::where('first_name', 'like', '%' . $key . '%')->Orwhere('last_name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get();
             $institutes = Institute::where('name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get();
         } else {
             $experts = Expert::where('first_name', 'like', '%' . $key . '%')->Orwhere('last_name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get();
             $institutes = Institute::where('name', 'like', '%' . $key . '%')->where('status', '=', 'active')->get();
         }
         $data = array();
         if (isset($experts) && count($experts) > 0) {
             foreach ($experts as $expert) {
                 $data[] = array('id' => $expert->id, 'name' => $expert->first_name . ' ' . $expert->last_name, 'group' => 'Experts');
             }
         }
         if (isset($institutes) && count($institutes) > 0) {
             foreach ($institutes as $institute) {
                 $data[] = array('id' => $institute->id, 'name' => $institute->name, 'group' => 'Institutes');
             }
         }
         if (isset($data) && count($data) > 0) {
             return json_encode(array('message' => 'found', 'data' => $data));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }