/** * Show the application dashboard to the user. * * @return Response */ public function index() { if (Auth::user()->summoner_id == 0) { return view('auth.connect'); } $data['captain'] = false; $data['summoner'] = Summoners::findOrFail(Auth::User()->summoner_id); if (Auth::User()->team_id) { $data['team'] = teams::findOrFail(Auth::User()->team_id); if ($data['team']->captain_id == Auth::User()->id) { $data['captain'] = true; } } $data['users'] = User::all(); $data['alerts'] = user_alert::all(); return view('home', $data); }
<th>Team</th> <th>Aantal leden</th> <th>Leden</th> <th>Captain</th> @if (Auth::User()->team_id == 0) <th>Join team</th> @endif </tr> </thead> <tbody> <?php $teams = teams::all(); $count = 0; ?> @foreach ($teams as $teaminfo) <tr> <td class="capitalize">{{ $teaminfo->name }}</td> <td>@foreach ($users as $user) @if ($user->team_id == $teaminfo->id) <?php $count++; ?> @endif @endforeach {{$count}}</td> <td><?php $user = User::where('team_id', '=', $teaminfo->id)->get(); ?> @foreach ($user as $username) {{ $username->name }} @endforeach</td>
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'] = 5; $input['team_id'] = $team->id; user_alert::create($input); } } $team->active = false; $team->save(); return redirect('home'); }
<li> <a href="#"></a> </li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" style="padding-top: 8px;"> <button class="btn btn-default notifications" type="button"> Messages <span class="badge">{{ $count }}</span> </button> </a> @if ($count != 0) <ul class="dropdown-menu"> @foreach ($alerts as $alert) @if ($alert->user_id == Auth::User()->id) <?php $teaminfo = teams::findOrFail($alert->team_id); ?> <li class="notification"> <a href="#" class="innernot"> <span class="glyphicon glyphicon-exclamation-sign"></span> You've been invited to a team "{{ $teaminfo->name }}" </a> <div class="btn-group" role="group" aria-label="invite"> <a type="button" class="btn btn-default" href="{{ url('team/addmember/' . $alert->user_id . '/' . $alert->team_id) }}">Accept</a> <a type="button" class="btn btn-default" href="#teams">View team</a> <a type="button" class="btn btn-default">Decline</a> </div> </li> <li class="divider"></li> @endif @endforeach
public function deleteAlertByUserId($user_id) { $alert = user_alert::where('user_id', '=', $user_id)->where('team_id', '=', Auth::User()->team_id)->first(); $team = teams::findorfail(Auth::User()->team_id); if ($team->captain_id == Auth::User()->id) { $alert->delete(); } return redirect('home'); }