Files
tippspiel/tippspiel/app/Http/Controllers/PagesController.php
2018-06-02 01:30:32 +02:00

50 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Team;
use App\Match;
use App\Tipp;
use App\Http\Requests\TippCreateRequest;
use Auth;
class PagesController extends Controller
{
function dashboard() {
$teams = Team::all();
$matches = Match::all();
$tipps = Tipp::where('user', Auth::user()->id)->get();
dd($tipps->where('matchid', 1));
return view('dashboard')->with([
'teams' => $teams,
'matches' => $matches,
'tipps' => $tipps,
]);
}
function createTipp($matchid) {
$teams = Team::all();
$matches = Match::findOrFail($matchid);
$teama = $teams->find($matches->teama)->name;
$teamb = $teams->find($matches->teamb)->name;
return view('tipp/create')->with([
'teama' => $teama,
'teamb' => $teamb,
'matchid' => $matchid,
]);
}
function storeTipp(TippCreateRequest $request) {
$tipp = new Tipp($request->all());
$tipp->user = Auth::user()->id;
$tipp->save();
return redirect('/dashboard');
}
}