2015-02-12 13:56:47 +01:00
|
|
|
<?php namespace App\Http\Controllers;
|
2015-03-10 16:12:02 +01:00
|
|
|
|
2015-03-14 14:36:03 +01:00
|
|
|
use App\Referent;
|
2015-03-16 19:47:57 +01:00
|
|
|
use Cookie;
|
2015-02-12 13:56:47 +01:00
|
|
|
class HomeController extends Controller {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2015-03-10 15:57:41 +01:00
|
|
|
//
|
2015-02-12 13:56:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the application dashboard to the user.
|
|
|
|
*
|
|
|
|
* @return Response
|
|
|
|
*/
|
2015-03-14 14:36:03 +01:00
|
|
|
|
|
|
|
public function index()
|
2015-02-12 13:56:47 +01:00
|
|
|
{
|
2015-03-20 19:53:40 +01:00
|
|
|
$values = json_decode(Cookie::get('trophee'));
|
2015-03-20 20:23:13 +01:00
|
|
|
if (!is_array($values))
|
2015-03-20 19:05:01 +01:00
|
|
|
$values = [0, 0, 0];
|
|
|
|
|
|
|
|
$nbOr = $values[2];
|
|
|
|
$nbArgent = $values[1];
|
|
|
|
$nbBronze = $values[0];
|
|
|
|
|
2015-03-16 19:47:57 +01:00
|
|
|
$idRef = Cookie::get('referent');
|
|
|
|
$ref = Referent::find($idRef);
|
2015-03-20 19:14:46 +01:00
|
|
|
return view('frontend/games', ['ref' => $ref, 'nbOr' => $nbOr, 'nbArgent' => $nbArgent, 'nbBronze' => $nbBronze]);
|
2015-03-14 14:36:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function choisirRef()
|
|
|
|
{
|
2015-03-17 17:22:11 +01:00
|
|
|
$refs = Referent::take(5)->select(['nom', 'prenom', 'image', 'id'])->get();
|
|
|
|
return view('frontend/home',['referents' => $refs]);
|
2015-03-14 14:36:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function changerRef($idRef)
|
|
|
|
{
|
|
|
|
if(Referent::find($idRef)) {
|
|
|
|
$response = new \Illuminate\Http\RedirectResponse(url('/'));
|
|
|
|
$response->withCookie(cookie()->forever('referent', $idRef));
|
|
|
|
return $response;
|
|
|
|
} else return $this->choisirRef();
|
2015-02-12 13:56:47 +01:00
|
|
|
}
|
|
|
|
|
2015-03-10 15:57:41 +01:00
|
|
|
/**
|
|
|
|
* Show referent games
|
|
|
|
*
|
|
|
|
* @param String $id
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function showReferentGames($id)
|
|
|
|
{
|
|
|
|
return view('referent_games', ['referent' => $id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show one referent game
|
|
|
|
*
|
|
|
|
* @param String $id
|
|
|
|
* @param String $idGame
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function showOneReferentGame($id, $idGame)
|
|
|
|
{
|
|
|
|
return view('one_referent_game', ['referent' => $id, 'game' => $idGame]);
|
|
|
|
}
|
|
|
|
|
2015-02-12 13:56:47 +01:00
|
|
|
}
|
2015-02-16 02:41:12 +01:00
|
|
|
|
|
|
|
?>
|