Exemplo n.º 1
0
 /**
  * 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);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit()
 {
     $user = UserProfile::find(Session::get(SiteSessions::USER_ID));
     $gender = UserProfileRepository::getUserGender();
     $addressType = UserProfileRepository::getAddressTypes();
     $instituteType = UserProfileRepository::getInstituteType();
     $country = BasicSiteRepository::getListOfCountries();
     $livingWith = UserProfileRepository::getLivingWithType();
     $gradeAverage = UserProfileRepository::getGradeAverageType();
     $sports = BasicSiteRepository::getSportTypes();
     if (SiteConstants::isTalent(Session::get(SiteSessions::USER_TYPE))) {
         $userProfile = UserProfile::find($user->user_id);
         return view('profile.talent.edit', compact('userProfile', 'gender', 'addressType', 'instituteType', 'country', 'livingWith', 'gradeAverage'));
     } else {
         if (SiteConstants::isCoach(Session::get(SiteSessions::USER_TYPE))) {
             $managerProfile = ManagerProfile::find($user->user_id);
             $managerCareerInformation = $managerProfile->managerCareerInformation()->get();
             return view('profile.manager.edit', compact('managerProfile', 'gender', 'addressType', 'instituteType', 'country', 'livingWith', 'gradeAverage', 'sports'));
         } else {
             if (Session::get(SiteSessions::USER_ID) == "") {
                 return redirect('/');
             }
         }
     }
 }