當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。