Configuration du jeu possible + bugfixs
This commit is contained in:
parent
4c61d4faa8
commit
33ac86a89b
@ -28,21 +28,43 @@ class APIController extends Controller {
|
|||||||
return Response::json($res->toArray());
|
return Response::json($res->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function searchOeuvres() {
|
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()): [];
|
$designations = (Input::get('designation', array()))? Input::get('designation', array()): [];
|
||||||
$domaines = (Input::get('domaine', array()))? Input::get('domaine', array()): [];
|
$domaines = (Input::get('domaine', array()))? Input::get('domaine', array()): [];
|
||||||
$matieres = (Input::get('matiere', array()))? Input::get('matiere', array()): [];
|
$matieres = (Input::get('matiere', array()))? Input::get('matiere', array()): [];
|
||||||
$techniques = (Input::get('technique', array()))?Input::get('technique', array()): [];
|
$techniques = (Input::get('technique', array()))?Input::get('technique', array()): [];
|
||||||
$debut = (Input::get('debut'))? Input::get('debut'): '';
|
$debut = (Input::get('debut'))? Input::get('debut'): '';
|
||||||
$fin = (Input::get('fin'))?Input::get('fin'): '';
|
$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)
|
//::whereIn('technique_id', $techniques)
|
||||||
//$res = Oeuvre::paginate(15);
|
//$res = Oeuvre::paginate(15);
|
||||||
//$listeoeuvres = Oeuvre::where('auteur_id', '=', Input::get('auteur'))->simplePaginate(1);
|
//$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]);
|
return view('backend/ref_listeoeuvres',['oeuvres' => $listeoeuvres]);
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ class GameController extends Controller {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
$oes = Oeuvre::orderByRaw("RAND()")->take(5)->get();
|
$oes = Oeuvre::orderByRaw("RAND()")->take(5)->get();
|
||||||
$dimension = 2;
|
|
||||||
$nbTab = 3;
|
$nbTab = 3;
|
||||||
|
$dimension = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('frontend/puzzle', ['oeuvres' => $oes, 'dimension' => $dimension, 'nbTab' => $nbTab]);
|
return view('frontend/puzzle', ['oeuvres' => $oes, 'dimension' => $dimension, 'nbTab' => $nbTab]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ class ReferentController extends Controller {
|
|||||||
$newConfig = new ConfigJeu();
|
$newConfig = new ConfigJeu();
|
||||||
$newConfig->referent_id = Auth::user()->id;
|
$newConfig->referent_id = Auth::user()->id;
|
||||||
$newConfig->nom = Input::get('nomListe');
|
$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();
|
$newConfig->save();
|
||||||
|
|
||||||
return redirect('/referent');
|
return redirect('/referent');
|
||||||
@ -138,8 +140,20 @@ class ReferentController extends Controller {
|
|||||||
$configjeu = $me->configjeu->find($id);
|
$configjeu = $me->configjeu->find($id);
|
||||||
$paramsToSave = Input::all();
|
$paramsToSave = Input::all();
|
||||||
unset($paramsToSave['_token']);
|
unset($paramsToSave['_token']);
|
||||||
$configjeu->parametres = json_encode($paramsToSave);
|
$valid = true;
|
||||||
$configjeu->save();
|
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() {
|
public function datation() {
|
||||||
return $this->hasMany('App\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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@extends('backend/template')
|
@extends('backend/template')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="container" style="padding-top:60px">
|
<div class="container">
|
||||||
<div class="row"><div class="col-md-12">
|
<div class="row"><div class="col-md-12">
|
||||||
@if (session('message_add'))
|
@if (session('message_add'))
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
@extends('backend/template')
|
@extends('backend/template')
|
||||||
@section('content')
|
@section('content')
|
||||||
@include('backend/ref_navbar')
|
@include('backend/ref_navbar')
|
||||||
<div class="container-fluid" style="margin-top:70px">
|
|
||||||
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class=" col-md-4">
|
@if (session('message'))
|
||||||
|
<div class="col-md-12"><div class="alert alert-success">
|
||||||
|
{{ Session::get('message') }}
|
||||||
|
</div></div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('erreur'))
|
||||||
|
<div class="col-md-12"><div class="alert alert-danger">
|
||||||
|
{{ Session::get('erreur') }}
|
||||||
|
</div></div>
|
||||||
|
@endif
|
||||||
|
<div class="col-md-4">
|
||||||
<div class="panel panel-primary">
|
<div class="panel panel-primary">
|
||||||
<div class="panel-heading">Mes listes d'Oeuvres</div>
|
<div class="panel-heading">Mes listes d'Oeuvres</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@ -153,17 +165,17 @@
|
|||||||
<div class="col-md-10 col-md-offset-2" style="margin-top:30px">
|
<div class="col-md-10 col-md-offset-2" style="margin-top:30px">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal" id="recherche">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputAuteur" class="col-sm-2 control-label">Auteur</label>
|
<label for="inputAuteur" class="col-sm-2 control-label">Auteur</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control" id="inputAuteur" placeholder="Auteur">
|
<select name="auteur[]" class="form-control" multiple><option>1</option><option>2</option></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputDomaine" class="col-sm-2 control-label">Domaine</label>
|
<label for="inputDomaine" class="col-sm-2 control-label">Domaine</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control" id="inputDomaine" placeholder="Domaine">
|
<input type="text" name="domaine" class="form-control" id="inputDomaine" placeholder="Domaine">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -204,11 +216,28 @@ $('#imagesSearched').on('click', '.pager a', function (event) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if ( $(this).attr('href') != '#' ) {
|
if ( $(this).attr('href') != '#' ) {
|
||||||
$("#imagesSearched").animate({ scrollTop: 0 }, "fast");
|
$("#imagesSearched").animate({ scrollTop: 0 }, "fast");
|
||||||
$('#imagesSearched').load($(this).attr('href'), function(){$("select.multiple").imagepicker();});
|
$.get($(this).attr('href'), $('#recherche').serialize(),
|
||||||
|
function(data){
|
||||||
|
$('#imagesSearched').empty();
|
||||||
|
$('#imagesSearched').append(data);
|
||||||
|
$("select.multiple").imagepicker();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#recherche").on('submit', function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
$('#imagesSearched').empty();
|
||||||
|
$('#imagesSearched').append("Recherche en cours...");
|
||||||
|
$.get("{{ URL::to('api/searchOeuvres') }}", $('#recherche').serialize(),
|
||||||
|
function(data){
|
||||||
|
$('#imagesSearched').empty();
|
||||||
|
$('#imagesSearched').append(data);
|
||||||
|
$("select.multiple").imagepicker();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
@yield('page-css')
|
@yield('page-css')
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body style="padding-top:70px">
|
||||||
|
|
||||||
@yield('content')
|
@yield('content')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user