当前位置: 首页>>代码示例>>PHP>>正文


PHP Team::findOrFail方法代码示例

本文整理汇总了PHP中app\Team::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::findOrFail方法的具体用法?PHP Team::findOrFail怎么用?PHP Team::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Team的用法示例。


在下文中一共展示了Team::findOrFail方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateTeam

 /**
  * 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');
 }
开发者ID:jpmartinspt,项目名称:table-soccer-tracker,代码行数:21,代码来源:TeamController.php

示例2: addJoinTeam

 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);
     }
 }
开发者ID:Panfen,项目名称:mango,代码行数:14,代码来源:TeamsController.php

示例3: getScheduleByTeam

 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);
 }
开发者ID:ProgrammingPeter,项目名称:nba-schedule-api,代码行数:17,代码来源:TeamController.php

示例4: create

 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'));
 }
开发者ID:Panfen,项目名称:mango,代码行数:17,代码来源:ArticlesController.php

示例5: teamwork

 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'));
 }
开发者ID:Panfen,项目名称:mango,代码行数:13,代码来源:UsersController.php

示例6: destroy

 /**
  * 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');
 }
开发者ID:pierangelo1982,项目名称:laravel_cyclingpassion,代码行数:12,代码来源:TeamController.php

示例7: declineInvitation

 /**
  * 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'));
 }
开发者ID:matyapav,项目名称:sh-league,代码行数:12,代码来源:UserController.php

示例8: destroy

 /**
  * 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');
     }
 }
开发者ID:HazimAnas,项目名称:skorely,代码行数:15,代码来源:TeamController.php

示例9: leaveCourse

 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();
 }
开发者ID:BootySYS,项目名称:bootysys,代码行数:7,代码来源:TeamsController.php

示例10: destroy

 /**
  * 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');
 }
开发者ID:rcabr497,项目名称:beerPong,代码行数:17,代码来源:TeamController.php

示例11: resetPassword

 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);
 }
开发者ID:jvanraemdonck,项目名称:Websitespel,代码行数:9,代码来源:TeamController.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $team = Team::findOrFail($id);
     return view('teams.show', compact('team'));
 }
开发者ID:VK-Labs,项目名称:CSSP,代码行数:11,代码来源:TeamsController.php

示例13: destroy

 /**
  * 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'));
     }
 }
开发者ID:matyapav,项目名称:sh-league,代码行数:16,代码来源:TeamController.php


注:本文中的app\Team::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。