/**
  * Update a team
  *
  * @param  Request $request
  * @param  Integer $id
  *
  * @return Response
  */
 public function updateTeam(Request $request, $id)
 {
     $this->validate($request, $this->rules($id), $this->messages());
     $team = Team::findOrFail($id);
     // Get players to associate with the team
     $name = $request->input('name');
     $players = $request->input('players', []);
     $team->name = $name;
     $team->players()->sync($players);
     $team->save();
     $request->session()->flash('message', sprintf('Team %s updated!', $team->name));
     return redirect()->route('team.list');
 }
Exemplo n.º 2
0
 public function addJoinTeam(Request $request)
 {
     $team = Team::findOrFail($request->get('id'));
     $user = $team->user;
     $r1 = TeamRequest::create(array('user_id' => \Auth::user()->id, 'team_id' => $request->get('id'), 'reason' => $request->get('reason'), 'status' => 0));
     $r2 = Message::create(array('from_user' => \Auth::user()->id, 'to_user' => $user->id, 'type' => 2, 'content' => '', 'isread' => 0));
     if ($r1 && $r2) {
         $this->setResult('请求成功');
         $this->succeed(true);
     } else {
         $this->setResult('请求失败');
         $this->fail(true);
     }
 }
 public function getScheduleByTeam($id)
 {
     if (!is_numeric($id)) {
         return new Http\Response("Incorrect Team Id", 400);
     }
     $team = null;
     // Try and see if the integer exists in our DB
     try {
         $team = Team::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return new Http\Response("Incorrect Team Id", 400);
     }
     // Concatenate the city and team name for the query
     $teamName = $team->city . ' ' . $team->team_name;
     $schedule = Schedule::where('home_team', $teamName)->orWhere('away_team', $teamName)->get();
     return new Http\Response($schedule, 200);
 }
Exemplo n.º 4
0
 public function create()
 {
     //获取所有分类
     $getCate = Cate::all();
     $cates = array();
     foreach ($getCate as $k => $v) {
         $cates[$v->id] = $v->name;
     }
     $teams = array();
     $teams[0] = '非团队博文';
     $teamMembers = TeamMember::where('user_id', \Auth()->user()->id)->get();
     foreach ($teamMembers as $teamMember) {
         $team = Team::findOrFail($teamMember->team_id);
         $teams[$team->id] = $team->title;
     }
     return view('member.articles.create', compact('cates', 'teams'));
 }
Exemplo n.º 5
0
 public function teamwork($id)
 {
     $action = 'teamwork';
     $user = User::findOrFail($id);
     $teams = array();
     $teamMembers = TeamMember::where('user_id', $id)->get();
     foreach ($teamMembers as $teamMember) {
         $team = Team::findOrFail($teamMember->team_id);
         $team['role'] = $teamMember->role;
         array_push($teams, $team);
     }
     return view("member.users.teamwork", compact('action', 'user', 'teams'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $team = Team::findOrFail($id);
     $team->delete();
     return redirect('admin/teams')->with('message', 'Team Member delete');
 }
Exemplo n.º 7
0
 /**
  * Declines invitation from team
  *
  * @param $id Id of team from which invitation comes
  * @return mixed redirection back with error or success msg
  */
 public function declineInvitation($id)
 {
     $team = Team::findOrFail($id);
     $team->sentInvitations()->detach(Auth::user()->id);
     return Redirect::back()->with('message', trans('messages.inv-declined'));
 }
Exemplo n.º 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $team = Team::findOrFail($id);
     if ($team->delete()) {
         return redirect('programs/' . Session::get('program'))->with('message', 'Team Deleted Successfully');
     } else {
         return redirect('programs/' . Session::get('program'))->with('message', 'Fail to Delete Team');
     }
 }
Exemplo n.º 9
0
 public function leaveCourse($course, $team)
 {
     $team = Team::findOrFail($team);
     $team->courses()->detach($course);
     Session::flash('success', 'Your application to the course has been removed');
     return redirect()->back();
 }
Exemplo n.º 10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     // This method has 2 ways of deleting a record in the database
     $team = Team::findOrFail($id);
     // Call the delete method
     $team->delete();
     // Or you can do it this way
     // Player::destroy($id);
     // redirect whereever you would like. Back to player index in this instance
     return redirect('teams');
 }
Exemplo n.º 11
0
 public function resetPassword($id)
 {
     $team = Team::findOrFail($id);
     $user = User::findOrFail($team->user_id);
     $password = $this->createPassword();
     $user->password = \Hash::make($password);
     $user->save();
     return redirect('admin/teams/' . $id)->with('password', $password);
 }
Exemplo n.º 12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $team = Team::findOrFail($id);
     return view('teams.show', compact('team'));
 }
Exemplo n.º 13
0
 /**
  * Remove the specified team from storage.
  *
  * @param  int  $id id of team which should be deleted
  * @return Response route where to redirect after delete
  */
 public function destroy($id)
 {
     $team = Team::findOrFail($id);
     if (Auth::user()->id == $team->captain->id || Auth::user()->hasRole('admin')) {
         $team->delete();
         return redirect('/teams');
     } else {
         return redirect('/teams')->withErrors(trans('messages.not-captain-or-admin'));
     }
 }