/**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     if (SiteConstants::isTalent(Session::get(SiteSessions::USER_TYPE))) {
         return ['dob' => 'date', 'gender' => 'in:' . implode(",", array_keys(UserProfileRepository::getUserGender())), 'height' => '', 'weight' => '', 'mobile_number' => 'numeric', 'home_number' => 'numeric', 'address_type' => 'in:' . implode(",", array_keys(UserProfileRepository::getAddressTypes())), 'zip' => 'numeric', 'country' => 'in:' . implode(",", array_keys(BasicSiteRepository::getListOfCountries())), 'graduation_year' => 'numeric', 'father_mobile_number' => 'numeric', 'father_living_with' => 'in:' . implode(",", array_keys(UserProfileRepository::getLivingWithType())), 'mother_mobile_number' => 'numeric', 'mother_living_with' => 'in:' . implode(",", array_keys(UserProfileRepository::getLivingWithType())), 'guardian_mobile_number' => 'numeric', 'guardian_living_with' => 'in:' . implode(",", array_keys(UserProfileRepository::getLivingWithType())), 'school_type' => 'in:' . implode(",", array_keys(UserProfileRepository::getInstituteType())), 'school_zip' => 'regex:/^\\d{4,5}$/', 'school_country' => 'in:' . implode(",", array_keys(BasicSiteRepository::getListOfCountries())), 'school_contact_person_phone' => 'numeric', 'grade_avg' => 'in:' . implode(",", array_keys(UserProfileRepository::getGradeAverageType())), 'sat_verbal' => 'regex:/^\\d+(\\.?\\d+)?$/', 'sat_math' => 'regex:/^\\d+(\\.?\\d+)?$/', 'sat_writing' => 'regex:/^\\d+(\\.?\\d+)?$/', 'sat_reading' => 'regex:/^\\d+(\\.?\\d+)?$/', 'sat_overall' => 'regex:/^\\d+(\\.?\\d+)?$/', 'pact' => 'regex:/^\\d+(\\.?\\d+)?$/', 'act' => 'regex:/^\\d+(\\.?\\d+)?$/', 'psat' => 'regex:/^\\d+(\\.?\\d+)?$/'];
     } else {
         if (SiteConstants::isManager(Session::get(SiteSessions::USER_TYPE))) {
             return ['dob' => 'date', 'gender' => 'in:' . implode(",", array_keys(UserProfileRepository::getUserGender())), 'mobile_number' => 'numeric', 'home_number' => 'numeric', 'address_type' => 'in:' . implode(",", array_keys(UserProfileRepository::getAddressTypes())), 'zip' => 'numeric', 'country' => 'in:' . implode(",", array_keys(BasicSiteRepository::getListOfCountries()))];
         }
     }
 }
 /**
  * Saving Manager Profile Data
  * @return mixed
  */
 public function updateProfile(Request $request)
 {
     $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'dob' => 'required|date', 'gender' => 'required | in:' . strtolower(implode(',', array_diff(UserProfileRepository::getUserGender(), [0 => "--Select Gender--"]))), 'nationality' => 'required', 'street_address' => 'required', 'city' => 'required', 'state' => 'required', 'zip' => 'required', 'country' => 'required', 'bio' => 'required']);
     if ($validator->fails()) {
         $this->updateRequestStatus(RequestStatusEnum::DATA_VALIDATION_ERROR);
         return $this->sendResponse($validator->failed());
     }
     $managerProfile = ManagerProfile::where('user_id', '=', session(SiteSessions::USER_ID))->first();
     $managerProfile->UpdateManagerProfile($request);
     return $this->sendResponse($managerProfile->toArray());
 }
 /**
  * Display page for adding Managers in the website
  * @return \Illuminate\View\View
  */
 public function addManager()
 {
     $manager_type = array_map('ucfirst', array_merge(['0' => '-- Select Option --'], BasicSiteRepository::getManagerTypes()));
     $management_level = array_map('ucfirst', array_merge(['0' => '-- Select Option --'], BasicSiteRepository::getUserManagementLevelType(SiteConstants::USER_MANAGER)));
     $sport_type = array_map('ucfirst', BasicSiteRepository::getSportTypes());
     $sport_gender = array_map('ucfirst', array_merge(['0' => '-- Select Option --'], SportsRepository::getSportsGender()));
     $country = array_map('ucfirst', BasicSiteRepository::getListOfCountries());
     $american_state = array_map('ucfirst', array_merge([0 => "-- Select State --"], BasicSiteRepository::getAmericanState()));
     $institution_type = array_map('ucfirst', UserProfileRepository::getInstituteType());
     return view('admin.managers_database.add_manager', compact('manager_type', 'management_level', 'sport_type', 'sport_gender', 'country', 'american_state', 'institution_type'));
 }
 /**
  * Opportunities for Sport Talent - either Aspiring professional or Student
  * @param $state
  * @param $institution_tye
  * @param $gender
  * @param $sport_type
  */
 public function talentOpportunities($state = null, $institution_type = null, $gender = null, $sport_type = null, $country = null)
 {
     $talent_management_level = Session::get(SiteSessions::USER_MANAGEMENT_LEVEL);
     $managers = null;
     switch ($talent_management_level) {
         case SiteConstants::USER_TALENT_MANAGEMENT_LEVEL_STUDENT:
             //Management level and Gender requested by the user.
             $managerManagementLevel = null;
             //If Institution type is "High School"
             if ($institution_type == 1) {
                 $managerManagementLevel = SiteConstants::USER_MANAGER_MANAGEMENT_LEVEL_HIGH_SCHOOL;
             } else {
                 if ($institution_type == 2) {
                     $managerManagementLevel = SiteConstants::USER_MANAGER_MANAGEMENT_LEVEL_UNIVERSITY;
                 }
             }
             $managers = ManagersDatabase::managerType(SiteConstants::USER_MANAGER_COACH)->managementLevel($managerManagementLevel)->state($state)->sportGender($gender)->sport($sport_type)->paginate(25);
             break;
         case SiteConstants::USER_TALENT_MANAGEMENT_LEVEL_ASPIRING_PRO:
             $managers = ManagersDatabase::country($country)->sport($sport_type)->sportGender($gender)->whereIn('management_level', [SiteConstants::USER_MANAGER_MANAGEMENT_LEVEL_AMATEUR, SiteConstants::USER_MANAGER_MANAGEMENT_LEVEL_PRO, SiteConstants::USER_MANAGER_MANAGEMENT_LEVEL_SEMI_PRO])->paginate(25);
             break;
     }
     $managers_already_contacted = DB::table("managers_contacted")->where('user_id', '=', Session::get(SiteSessions::USER_ID))->lists('manager_id');
     $userProfile = UserProfile::find(Session::get(SiteSessions::USER_ID));
     $userProfile->getMutatedData = false;
     $sport_gender = array_map('ucfirst', array_merge(['0' => '-- Select Option --'], SportsRepository::getSportsGender()));
     $state = array_map('ucfirst', array_merge(['0' => "-- Select State --"], BasicSiteRepository::getAmericanState()));
     $institution_type = array_map('ucfirst', UserProfileRepository::getInstituteType());
     $country = array_map('ucfirst', BasicSiteRepository::getListOfCountries());
     return view('database.talent_database_search_result', compact('managers', 'managers_already_contacted', 'userProfile', 'sport_gender', 'state', 'institution_type', 'country'));
 }
 /**
  * Storing corresponding text of the index selected by the admin
  * @param $institution_type
  */
 public function setinstitutionTypeAttribute($institution_type)
 {
     $this->attributes["institution_type"] = UserProfileRepository::getInstituteType()[$institution_type];
 }
 /**
  * Mutating grade_avg before presenting it to a user
  * @param $grade_avg
  * @return mixed
  */
 public function getgradeAvgAttribute($grade_avg)
 {
     if ($this->getMutatedData) {
         return array_search($grade_avg, UserProfileRepository::getGradeAverageType());
     }
     return ucfirst($grade_avg);
 }
 /**
  * Mutating value to have index value after retrieving it from database
  * @param $school_type
  */
 public function getschoolTypeAttribute($school_type)
 {
     if ($this->getMutatedData) {
         return array_search($school_type, UserProfileRepository::getInstituteType());
     }
     return $school_type;
 }
 /**
  * Function to handle Edit CV request for Talent only
  * @param $id
  */
 public function editCV()
 {
     $country = BasicSiteRepository::getListOfCountries();
     $clubDataMap = SportsRepository::getClubDataMap($this->getSportDataMap(Session::get(SiteSessions::USER_SPORT_TYPE)), true);
     $schoolDataMap = SportsRepository::getSchoolDataMap($this->getSportDataMap(Session::get(SiteSessions::USER_SPORT_TYPE)), true);
     $sportPositions = array_map('ucfirst', SportsRepository::getSportPositions(Session::get(SiteSessions::USER_SPORT_TYPE)));
     $clubLeagueLevel = SportsRepository::getClubLeagueLevel();
     $clubLeagueStatus = SportsRepository::getClubLeagueStatus();
     $schoolTeamReputation = SportsRepository::getSchoolTeamReputation();
     $schoolTeamSideLevel = SportsRepository::getSchoolTeamSideLevel();
     $institutionType = UserProfileRepository::getInstituteType();
     if (SiteConstants::isTalent(Session::get(SiteSessions::USER_TYPE))) {
         $talentProfile = UserProfile::find(Session::get(SiteSessions::USER_ID));
         $clubCareerInformation = $talentProfile->careerInformation()->where('career_type', '=', SiteConstants::CAREER_TYPE_CLUB)->get();
         $schoolCareerInformation = $talentProfile->careerInformation()->where('career_type', '=', SiteConstants::CAREER_TYPE_SCHOOL)->get();
         return view('profile.talent.editCV', compact('talentProfile', 'country', 'clubDataMap', 'schoolDataMap', 'sportPositions', 'clubLeagueLevel', 'clubLeagueStatus', 'schoolTeamReputation', 'schoolTeamSideLevel', 'institutionType', 'clubCareerInformation', 'schoolCareerInformation'));
     }
 }