Presque terminé
This commit is contained in:
@ -54,12 +54,12 @@ class APIController extends Controller {
|
||||
//$listeoeuvres = Oeuvre::where('auteur_id', '=', Input::get('auteur'))->simplePaginate(1);
|
||||
|
||||
$auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
||||
$designations = (Input::get('designation', array()))? Input::get('designation', array()): [];
|
||||
$designations = (Input::get('designation')) ? Input::get('designation') : "";
|
||||
$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)
|
||||
$listeoeuvres = Oeuvre::auteurFilter($auteurs)
|
||||
->techniqueFilter($techniques)
|
||||
->designationFilter($designations)
|
||||
->domaineFilter($domaines)
|
||||
|
@ -2,7 +2,11 @@
|
||||
|
||||
use App\Referent;
|
||||
use App\ConfigJeu;
|
||||
use App\Auteur;
|
||||
use App\Domaine;
|
||||
use App\Oeuvre;
|
||||
use App\Matiere;
|
||||
use App\Technique;
|
||||
use Input;
|
||||
use Request;
|
||||
use Response;
|
||||
@ -103,7 +107,9 @@ class ReferentController extends Controller {
|
||||
$meslistes = $me->configjeu;
|
||||
$mesoeuvres = $me->configjeu->find($idListe);
|
||||
|
||||
return view('backend/ref_home',['meslistes' => $meslistes, 'mesoeuvres' => $mesoeuvres, 'me' => $me, 'listeoeuvres' => $listeoeuvres]);
|
||||
return view('backend/ref_home',['meslistes' => $meslistes, 'mesoeuvres' => $mesoeuvres, 'me' => $me, 'listeoeuvres' => $listeoeuvres,
|
||||
'auteurs' => Auteur::all(), 'domaines' => Domaine::all(), 'matieres' => Matiere::all(), 'techniques' => Technique::all()
|
||||
]);
|
||||
}
|
||||
|
||||
public function changerParamListe() {
|
||||
|
@ -28,48 +28,34 @@ class Oeuvre extends Model {
|
||||
return $this->hasMany('App\Datation');
|
||||
}
|
||||
|
||||
public function scopeAuthorFilter($query, $array)
|
||||
public function scopeAuteurFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('auteur', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
return $query->whereIn('auteur_id', $array);
|
||||
}
|
||||
|
||||
public function scopeDesignationFilter($query, $array)
|
||||
public function scopeDesignationFilter($query, $designation)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('designation', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
if ($designation == "") return $query;
|
||||
return $query->where('designation', 'like', '%'.$designation.'%');
|
||||
}
|
||||
|
||||
public function scopeDomaineFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('domaine', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
return $query->whereIn('domaine_id', $array);
|
||||
|
||||
}
|
||||
|
||||
public function scopeMatiereFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('matiere', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
}
|
||||
return $query->whereIn('matiere_id', $array);
|
||||
|
||||
}
|
||||
public function scopeTechniqueFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('technique', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
return $query->whereIn('technique_id', $array);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user