2015-02-12 18:58:03 +01:00
|
|
|
<?php namespace App\Http\Controllers;
|
|
|
|
|
2015-02-25 19:48:34 +01:00
|
|
|
use Response;
|
2015-03-14 14:36:03 +01:00
|
|
|
use App\Referent;
|
|
|
|
use App\ConfigJeu;
|
|
|
|
use App\Oeuvre;
|
|
|
|
use Cookie;
|
2015-02-12 18:58:03 +01:00
|
|
|
class GameController extends Controller {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2015-02-15 07:12:44 +01:00
|
|
|
//
|
2015-02-12 18:58:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the application dashboard to the user.
|
|
|
|
*
|
|
|
|
* @return Response
|
|
|
|
*/
|
2015-03-14 14:36:03 +01:00
|
|
|
public function chooseDifMemo() {
|
|
|
|
return view('frontend/memo_level');
|
|
|
|
}
|
|
|
|
|
2015-03-16 14:07:32 +01:00
|
|
|
public function playMemo($niveau) {
|
2015-03-15 19:38:11 +01:00
|
|
|
$idRef = Cookie::get('referent');
|
2015-03-16 14:07:32 +01:00
|
|
|
$configjeu = Referent::find($idRef)->configjeu()->where('actifMemo', '=', '1')->first();
|
|
|
|
if($configjeu && count($configjeu->oeuvres) >= 1) {
|
|
|
|
$oes = $configjeu->oeuvres;
|
|
|
|
} else {
|
|
|
|
$oes = Oeuvre::orderByRaw("RAND()")->take(5)->get();
|
|
|
|
}
|
|
|
|
return view('frontend/memo', ['oeuvres' => $oes, 'niveau' => $niveau]);
|
2015-03-14 14:36:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function chooseDifPuzzle() {
|
|
|
|
return view('frontend/puzzle_level');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function playPuzzle($niveau) {
|
|
|
|
|
|
|
|
$idRef = Cookie::get('referent');
|
|
|
|
$ref = Referent::find($idRef);
|
|
|
|
$configjeu = $ref->configjeu()->where('actifPuzzle', '=', '1')->first();
|
|
|
|
|
|
|
|
if($configjeu && count($configjeu->oeuvres) >= 1) {
|
|
|
|
$oes = $configjeu->oeuvres;
|
|
|
|
$params = json_decode($configjeu->parametres);
|
|
|
|
$nbTab = $params->pt;
|
|
|
|
$dimension = $params->{ "p".$niveau};
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$oes = Oeuvre::orderByRaw("RAND()")->take(5)->get();
|
|
|
|
$nbTab = 3;
|
2015-03-14 16:11:11 +01:00
|
|
|
$dimension = 2;
|
2015-03-14 14:36:03 +01:00
|
|
|
}
|
2015-03-14 16:11:11 +01:00
|
|
|
|
2015-03-14 14:36:03 +01:00
|
|
|
return view('frontend/puzzle', ['oeuvres' => $oes, 'dimension' => $dimension, 'nbTab' => $nbTab]);
|
|
|
|
|
|
|
|
}
|
2015-02-12 18:58:03 +01:00
|
|
|
public function index()
|
|
|
|
{
|
2015-02-17 15:56:30 +01:00
|
|
|
$res = User::referents()->get();
|
2015-02-16 02:41:12 +01:00
|
|
|
return view('home',['referent' => $res]);
|
2015-02-12 18:58:03 +01:00
|
|
|
}
|
|
|
|
|
2015-03-10 16:10:52 +01:00
|
|
|
public function findReferents($reg) {
|
|
|
|
|
|
|
|
$res = User::referents()->name($reg)->get();
|
|
|
|
return Response::json($res->toArray());
|
|
|
|
}
|
|
|
|
|
2015-02-15 17:10:23 +01:00
|
|
|
/**
|
|
|
|
* Show referent games
|
|
|
|
*
|
|
|
|
* @param String $id
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function showReferentGames($id)
|
|
|
|
{
|
2015-03-10 15:27:36 +01:00
|
|
|
$listeOeuvre = $ListeOeuvre = ListeOeuvre::ofUser($id)->activeListOeuvre()->first();
|
|
|
|
if($listeOeuvre == '')
|
|
|
|
$games = [];
|
|
|
|
else
|
|
|
|
$games = $listeOeuvre->jeux()->get();
|
|
|
|
|
|
|
|
return view('referent_games', ['games' => $games]);
|
2015-02-15 17:10:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 18:58:03 +01:00
|
|
|
}
|