/** * 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); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Request::all(); $summonername = str_replace(' ', '', $input['name']); $result = file_get_contents('https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/' . $summonername . '?api_key=6cabd680-61d0-48d5-9ee5-271f19c45624'); $input['summoner_id'] = json_decode($result)->{$summonername}->id; $input['user_id'] = Auth::user()->id; Summoners::create($input); $summoner_id = Summoners::where('user_id', '=', Auth::user()->id)->get(); foreach ($summoner_id as $value) { $user['summoner_id'] = $value->id; } $user = User::findorfail(Auth::user()->id); $user->summoner_id = $value->id; $user->save(); return redirect('home'); }
<th>Email</th> <th class="adminoptions">Options</th> </tr> </thead> <tbody> @foreach ($users as $user) <tr> <td>{{ $user->name }}</td> <td><?php if ($user->summoner_id != 0) { $summoner = Summoners::findorfail($user->summoner_id); echo $summoner->name; } else { echo "none"; } ?> </td> <td><?php if ($user->team_id != 0) { $team = teams::findorfail($user->team_id); echo $team->name; } else { echo "none"; } ?>
echo $summoners->name; ?> </td> <td class="capitalize"><?php if ($user->team_id > 0) { $team = Teams::findOrFail($user->team_id); echo $team->name; } else { echo "No team"; } ?> </td> <td><?php $summoners = Summoners::findOrFail($user->summoner_id); echo $summoners->lane; ?> </td> @if (($captain == true) && ($user->id != Auth::User()->id) && ($user->team_id == 0)) <td><a class="btn btn-default" type="button" href="{{ url('team/invite/' . $user->id) }}">Invite</a></td> @endif </tr> @endforeach </tbody> </table> </div> <div class="panel panel-primary">