本文整理汇总了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');
}
示例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);
}
}
示例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);
}
示例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'));
}
示例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'));
}
示例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');
}
示例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'));
}
示例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');
}
}
示例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();
}
示例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');
}
示例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);
}
示例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'));
}
示例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'));
}
}