?> ">Accept</a> <a type="button" class="btn btn-default" href="#users">View user</a> <a type="button" class="btn btn-default" href="<?php echo url('team/delete-alert/' . $alert->id); ?> ">Decline</a> </div> </li> <li class="divider"></li> <?php } elseif ($alert->alert_id == 3 && $alert->user_id == Auth::User()->id) { ?> <?php $teaminfo = deleted_teams::findOrFail($alert->team_id); ?> <li class="notification"> <a href="#" class="innernot"> <span class="glyphicon glyphicon-exclamation-sign"></span> The team (<?php echo $teaminfo->name; ?> ) that you where in is deleted by the captain. </a> <div class="btn-group" role="group" aria-label="invite"> <a type="button" class="btn btn-default" href="<?php echo url('team/delete-alert/' . $alert->id); ?> ">Ok</a> </div>
public function delete() { $users = User::all(); $team = teams::findorfail(Auth::User()->team_id); foreach ($users as $user) { if ($user->team_id == $team->id) { $user->team_id = 0; $user->save(); $input['user_id'] = $user->id; $input['alert_id'] = 3; $input['team_id'] = $team->id; user_alert::create($input); } } $team_input['id'] = $team->id; $team_input['captain_id'] = $team->captain_id; $team_input['name'] = $team->name; deleted_teams::create($team_input); $team->delete(); return redirect('home'); }