本文整理汇总了PHP中app\Team::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::destroy方法的具体用法?PHP Team::destroy怎么用?PHP Team::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Team
的用法示例。
在下文中一共展示了Team::destroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
Team::destroy($id);
return redirect('admin/team');
}
示例2: leave
/**
* Allow user to leave team
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function leave()
{
$user = \Auth::user()->with(['team', 'team.members'])->first();
$team_id = $user->team->id;
// Remove user's team
$user->team_id = null;
$user->save();
\Log::debug("User removed from team {$team_id}");
// Clean up team if no more users
if (count($user->team->members) - 1 == 0) {
Team::destroy($team_id);
\Log::info("Team {$team_id} deleted.");
}
return redirect('/');
}