/** * Handling request for user who is logged in into the website * @param $request */ public function handleRequestForAuthenticatedUser($request, $next) { $loggedInUser = Auth::user(); $userProfileVisiting = UserProfile::find($request->route()->parameter('id')); if (strtolower($request->method()) == "get" && SiteConstants::isTalent($loggedInUser->user_type) && (SiteConstants::isManager($userProfileVisiting->user_type) || SiteConstants::isAdmin($userProfileVisiting->user_type))) { return redirect('/profile'); } 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()))]; } } }
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); }
/** * 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()) { 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); }
/** * 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'); }