/**
  * Handling request for user who is not logged in into to site
  * @param $request
  */
 public function handleRequestForExternalUser($request, $next)
 {
     $userProfileVisiting = UserProfile::find($request->route()->parameter('id'));
     if (strtolower($request->method()) == "get" && (SiteConstants::isManager($userProfileVisiting->user_type) || SiteConstants::isAdmin($userProfileVisiting->user_type))) {
         return redirect('/');
     }
     return $next($request);
 }
 /**
  * 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()))];
         }
     }
 }
Esempio n. 3
0
 public function setmanagementLevelAttribute($management_level)
 {
     if (SiteConstants::isManager($this->attributes['user_type'])) {
         $this->attributes['management_level'] = BasicSiteRepository::getUserManagementLevelType(SiteConstants::USER_MANAGER)[$management_level];
     } else {
         if (SiteConstants::isTalent($this->attributes['user_type'])) {
             $this->attributes['management_level'] = BasicSiteRepository::getUserManagementLevelType(SiteConstants::USER_TALENT)[$management_level];
         }
     }
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     if (SiteConstants::isManager($data["user_type"])) {
         $userType = BasicSiteRepository::getManagerTypes()[$data["managerType"]];
         return User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $userType, 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]);
     } else {
         if (SiteConstants::isTalent($data["user_type"])) {
             return User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $data['user_type'], 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]);
         }
     }
 }
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     if ($user && SiteConstants::isTalent($user->user_type)) {
         return redirect('/home');
     } else {
         if ($user && SiteConstants::isManager($user->user_type)) {
             return redirect('/manager');
         }
     }
     return view('welcome');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         $user = Auth::user();
         if (SiteConstants::isTalent($user->user_type)) {
             return new RedirectResponse(url('/profile'));
         } else {
             if (SiteConstants::isManager($user->user_type)) {
                 return new RedirectResponse(url('/manager'));
             }
         }
     }
     return $next($request);
 }
Esempio n. 7
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     if (SiteConstants::isManager($data["user_type"])) {
         $userType = BasicSiteRepository::getManagerTypes()[$data["managerType"]];
         $user = null;
         $user = DB::transaction(function () use($data, $user, $userType) {
             $user = User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $userType, 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]);
             $user->managerProfile()->create(['first_name' => '', 'middle_name' => '', 'last_name' => '']);
             return $user;
         });
         return $user;
     } else {
         if (SiteConstants::isTalent($data["user_type"])) {
             return User::create(['username' => $data['username'], 'password' => $data['password'], 'active' => 0, 'user_type' => $data['user_type'], 'management_level' => $data['management_level'], 'sport_type' => $data['sport_type'], 'profile_image_path' => $data['profile_image_path'], 'confirmation_token' => bcrypt(time())]);
         }
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('/');
         }
     }
     $user = $this->auth->user();
     if (!SiteConstants::isTalent($user->user_type) && !SiteConstants::isManager($user->user_type) && !SiteConstants::isCoach($user->user_type) && !SiteConstants::isAgent($user->user_type)) {
         return redirect('auth/logout');
     }
     if (!SiteConstants::isTalent($user->user_type)) {
         return redirect('/');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             if ($request->is('api/manager/*')) {
                 return response()->json([], RequestStatusEnum::USER_NOT_LOGGED_IN);
             }
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('/');
         }
     }
     $user = $this->auth->user();
     if (!SiteConstants::isManager($user->user_type)) {
         return abort(404);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('/');
         }
     }
     $user = $this->auth->user();
     if (!SiteConstants::isTalent($user->user_type) && !SiteConstants::isManager($user->user_type) && !SiteConstants::isCoach($user->user_type) && !SiteConstants::isAgent($user->user_type)) {
         return redirect('auth/logout');
     }
     //Temporary Middleware for Managers
     if (SiteConstants::isManager($user->user_type)) {
         return view("profile.manager.under_construction");
     }
     return $next($request);
 }
 /**
  *Requesting recommendation from the person as specified in the form
  * @param Request $request
  */
 public function request(HttpRequest $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required', 'email' => 'required|email', 'recommender_type' => 'required|in:' . SiteConstants::RECOMMENDER_COACH . "," . SiteConstants::RECOMMENDER_ATHLETE]);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors());
     }
     $recommendation = new Recommendations();
     $recommendation->user_id = Session::get(SiteSessions::USER_ID);
     $recommendation->status = SiteConstants::RECOMMENDATION_STATUS_WAITING;
     $recommendation->name = $request->get("name");
     $recommendation->email = $request->get("email");
     $recommendation->recommender_type = SiteConstants::getRecommenderType()[$request->get("recommender_type")];
     $recommendation->save();
     $userProfile = UserProfile::find(Session::get(SiteSessions::USER_ID));
     //Send Mail to the Desired Person for recommendation
     Event::fire(new SendMail(SendMail::MAIL_TYPE_REQUEST_RECOMMENDATION, $recommendation->email, [], ["recommendation" => $recommendation, "userProfile" => $userProfile]));
     Session::flash('recommendation_request_status', 'success');
     return redirect()->back();
 }
 /**
  * Showing CV information of a talent or Manager
  * @param $user_id
  */
 public function viewCV($user_id)
 {
     if ($this->checkIfGuestDoNotHavePermission($user_id, UserSettings::PRIVACY_TYPE_PROFILE)) {
         return redirect('/');
     }
     $userProfile = null;
     try {
         $userProfile = UserProfile::findOrFail($user_id);
         $userProfile->getMutatedData = false;
     } catch (ModelNotFoundException $e) {
         return abort(404);
     }
     if (SiteConstants::isTalent($userProfile->user_type)) {
         $talentProfile = $userProfile;
         return view('profile.talent.viewTalentCV', compact('talentProfile'));
     } else {
         if (SiteConstants::isManager($userProfile->user_type)) {
             $managerProfile = ManagerProfile::find($userProfile->user_id);
             $careerInformation = $managerProfile->managerCareerInformation;
             return view('profile.manager.viewManagerCV', compact('managerProfile', 'careerInformation'));
         }
     }
     return redirect('profile');
 }