Ejemplo n.º 1
0
 public function changeTeamNameAndLanguage($id, Requests\ChangeTeamNameAndLanguageRequest $request)
 {
     $requestArray = $request->all();
     // Change the team's name
     if ($requestArray['teamName'] != "") {
         \App\team::where('id', $id)->update(['teamName' => $requestArray['teamName']]);
     }
     // Change the team's language
     if ($requestArray['teamLanguage'] != 'nochange') {
         \App\team::where('id', $id)->update(['language' => $requestArray['teamLanguage']]);
     }
     return redirect('/teams');
 }
 public function homepage()
 {
     $user = \Auth::user();
     $user_id = $user->id;
     $admin_id = admin::where('id', '=', $user_id)->get();
     //return $admin_id;
     //$admin_id = $admin_id[0]->id;
     if (count($admin_id)) {
         $teams = team::all();
         $teamnames = array();
         foreach ($teams as $t) {
             array_push($teamnames, $t->teamName);
         }
         return view('admin', compact('teamnames'));
     } else {
         //return $pref[0]->python;
         // return $user->id;
         $teamcontent = team_contents::where('studentID', '=', $user->id)->get(array('teamID'));
         $teamname = array();
         foreach ($teamcontent as $teamId) {
             $name = team::where('teamID', '=', $teamId->teamID)->get(array('teamName'));
             array_push($teamname, $name[0]->teamName);
         }
         // return $teamname;
         // return $user;
         //$team = find($user->)
         return view('home', compact('teamname'), compact('user'));
     }
 }
 public function homepage()
 {
     $user = \Auth::user();
     $user_id = $user->id;
     $admin_id = admin::where('id', '=', $user_id)->get();
     if (count($admin_id)) {
         $teams = team::all();
         $competitions = competition::all();
         return view('admin', compact('teams', 'competitions'));
     } else {
         $teamcontent = team_contents::where('studentID', '=', $user->id)->get(array('teamID'));
         $teamname = array();
         foreach ($teamcontent as $teamId) {
             $name = team::where('teamID', '=', $teamId->teamID)->get(array('teamName'));
             $t = array();
             array_push($t, $teamId->teamID);
             array_push($t, $name[0]->teamName);
             array_push($teamname, $t);
         }
         return view('home', compact('teamname', 'user'));
     }
 }