Configuration du jeu possible + bugfixs
This commit is contained in:
@ -28,21 +28,43 @@ class APIController extends Controller {
|
||||
return Response::json($res->toArray());
|
||||
}
|
||||
|
||||
|
||||
public function searchOeuvres() {
|
||||
/*$auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
||||
/* $auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
||||
$designations = (Input::get('designation', array()))? Input::get('designation', array()): [];
|
||||
$domaines = (Input::get('domaine', array()))? Input::get('domaine', array()): [];
|
||||
$matieres = (Input::get('matiere', array()))? Input::get('matiere', array()): [];
|
||||
$techniques = (Input::get('technique', array()))?Input::get('technique', array()): [];
|
||||
$debut = (Input::get('debut'))? Input::get('debut'): '';
|
||||
$fin = (Input::get('fin'))?Input::get('fin'): '';
|
||||
|
||||
$res = Oeuvre::authorFilter($auteurs)
|
||||
->techniqueFilter($techniques)
|
||||
->designationFilter($designations)
|
||||
->domaineFilter($domaines)
|
||||
->matiereFilter($matieres)
|
||||
->debutFilter($debut)
|
||||
->finFilter($fin)
|
||||
->paginate(15);
|
||||
|
||||
return Response::json($res->toArray());
|
||||
*/
|
||||
//::whereIn('technique_id', $techniques)
|
||||
//$res = Oeuvre::paginate(15);
|
||||
//$listeoeuvres = Oeuvre::where('auteur_id', '=', Input::get('auteur'))->simplePaginate(1);
|
||||
|
||||
$listeoeuvres = Oeuvre::simplePaginate(5);
|
||||
$auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
||||
$designations = (Input::get('designation', array()))? Input::get('designation', array()): [];
|
||||
$domaines = (Input::get('domaine', array()))? Input::get('domaine', array()): [];
|
||||
$matieres = (Input::get('matiere', array()))? Input::get('matiere', array()): [];
|
||||
$techniques = (Input::get('technique', array()))?Input::get('technique', array()): [];
|
||||
|
||||
$listeoeuvres = Oeuvre::authorFilter($auteurs)
|
||||
->techniqueFilter($techniques)
|
||||
->designationFilter($designations)
|
||||
->domaineFilter($domaines)
|
||||
->matiereFilter($matieres)
|
||||
->simplePaginate(15);
|
||||
|
||||
return view('backend/ref_listeoeuvres',['oeuvres' => $listeoeuvres]);
|
||||
|
||||
|
@ -49,10 +49,10 @@ class GameController extends Controller {
|
||||
|
||||
} else {
|
||||
$oes = Oeuvre::orderByRaw("RAND()")->take(5)->get();
|
||||
$dimension = 2;
|
||||
$nbTab = 3;
|
||||
$dimension = 2;
|
||||
}
|
||||
|
||||
|
||||
return view('frontend/puzzle', ['oeuvres' => $oes, 'dimension' => $dimension, 'nbTab' => $nbTab]);
|
||||
|
||||
}
|
||||
|
@ -82,6 +82,8 @@ class ReferentController extends Controller {
|
||||
$newConfig = new ConfigJeu();
|
||||
$newConfig->referent_id = Auth::user()->id;
|
||||
$newConfig->nom = Input::get('nomListe');
|
||||
$newConfig->parametres = json_encode(['p1' => 2, 'p2' => 3, 'p3' => 4, 'pt' => '3',
|
||||
'm1' => 2, 'm2' => 3, 'm3' => 4, 'mt' => '3']);
|
||||
$newConfig->save();
|
||||
|
||||
return redirect('/referent');
|
||||
@ -138,8 +140,20 @@ class ReferentController extends Controller {
|
||||
$configjeu = $me->configjeu->find($id);
|
||||
$paramsToSave = Input::all();
|
||||
unset($paramsToSave['_token']);
|
||||
$configjeu->parametres = json_encode($paramsToSave);
|
||||
$configjeu->save();
|
||||
$valid = true;
|
||||
foreach($paramsToSave as $p) {
|
||||
if(!(is_numeric($p) && $p > 0 && $p<= 10)) $valid = false;
|
||||
}
|
||||
|
||||
|
||||
if(!$valid)
|
||||
Session::flash('erreur', 'Les paramètres du jeu sont incorrect. Rééessayez.');
|
||||
else {
|
||||
Session::flash('message', 'Vos modifications ont été prisent en compte.');
|
||||
$configjeu->parametres = json_encode($paramsToSave);
|
||||
$configjeu->save();
|
||||
}
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,4 +27,49 @@ class Oeuvre extends Model {
|
||||
public function datation() {
|
||||
return $this->hasMany('App\Datation');
|
||||
}
|
||||
|
||||
public function scopeAuthorFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('auteur', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeDesignationFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('designation', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeDomaineFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('domaine', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeMatiereFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('matiere', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeTechniqueFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('technique', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user