modified: SRC/app/Http/Controllers/ReferentController.php
modified: SRC/app/Http/routes.php modified: SRC/app/Models/Oeuvre.php modified: SRC/resources/views/referent.blade.php
This commit is contained in:
parent
2399b7eace
commit
d9cc1e2a4c
@ -10,6 +10,7 @@ use App\Models\Designation;
|
||||
use App\Models\Domaine;
|
||||
use App\Models\Matiere;
|
||||
use App\Models\Technique;
|
||||
use App\Models\Oeuvre;
|
||||
use Response;
|
||||
|
||||
|
||||
@ -120,4 +121,25 @@ class ReferentController extends Controller {
|
||||
return Response::json(array());
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$auteurs = Input::get('auteur', array());
|
||||
$designations = Input::get('designation', array());
|
||||
$domaines = Input::get('domaine', array());
|
||||
$matieres = Input::get('matiere', array());
|
||||
$techniques = Input::get('technique', array());
|
||||
$debut = Input::get('debut');
|
||||
$fin = Input::get('fin');
|
||||
|
||||
//echo Oeuvre::find(22)->domaine()->get();
|
||||
echo count(Oeuvre::techniqueFilter($techniques)
|
||||
->authorFilter($auteurs)
|
||||
->designationFilter($designations)
|
||||
->domaineFilter($domaines)
|
||||
->matiereFilter($matieres)
|
||||
->debutFilter($debut)
|
||||
->finFilter($fin)
|
||||
->get());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ Route::group(['middleware' => 'auth'], function ()
|
||||
Route::post('addListeOeuvre', 'ReferentController@addListeOeuvre');
|
||||
Route::get('showListOeuvres/{id}', 'ReferentController@showListeOeuvres');
|
||||
Route::post('setListOeuvres', 'ReferentController@setListOeuvres');
|
||||
Route::post('search', 'ReferentController@search');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'admin'], function ()
|
||||
|
@ -7,4 +7,149 @@ class Oeuvre extends Model {
|
||||
protected $table = 'oeuvre';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function designations()
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Designation', 'assodesignationaoeuvre');
|
||||
}
|
||||
|
||||
public function auteurs()
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Auteur', 'assoauteuraoeuvre');
|
||||
}
|
||||
|
||||
public function technique()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Technique', 'idtechnique', 'id');
|
||||
}
|
||||
|
||||
public function domaine()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Domaine', 'iddomaine', 'id');
|
||||
}
|
||||
|
||||
public function matiere()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Matiere', 'idmatiere', 'id');
|
||||
}
|
||||
|
||||
public function datation()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Datation', 'iddate', 'id');
|
||||
}
|
||||
|
||||
public function scopeAuthorFilter($query, $array)
|
||||
{
|
||||
foreach ($array as $author_id){
|
||||
|
||||
if ($author_id === reset($array)){
|
||||
$query->whereHas('auteurs', function($q) use ($author_id)
|
||||
{
|
||||
$q->where('id', '=', $author_id);
|
||||
});
|
||||
}else{
|
||||
$query->orWhereHas('auteurs', function($q) use ($author_id)
|
||||
{
|
||||
$q->where('id', '=', $author_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function scopeDesignationFilter($query, $array)
|
||||
{
|
||||
$q = $query;
|
||||
|
||||
foreach ($array as $designation_id){
|
||||
|
||||
if ($designation_id === reset($array)){
|
||||
$query->whereHas('designations', function($q) use ($designation_id)
|
||||
{
|
||||
$q->where('id', '=', $designation_id);
|
||||
});
|
||||
}else{
|
||||
$query->orWhereHas('designations', function($q) use ($designation_id)
|
||||
{
|
||||
$q->where('id', '=', $designation_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function scopeDomaineFilter($query, $array)
|
||||
{
|
||||
$q = $query;
|
||||
|
||||
foreach ($array as $domaine_id){
|
||||
|
||||
if ($domaine_id === reset($array)){
|
||||
$query->whereHas('domaine', function($q) use ($domaine_id)
|
||||
{
|
||||
$q->where('id', '=', $domaine_id);
|
||||
});
|
||||
}else{
|
||||
$query->orWhereHas('domaine', function($q) use ($domaine_id)
|
||||
{
|
||||
$q->where('id', '=', $domaine_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function scopeMatiereFilter($query, $array)
|
||||
{
|
||||
foreach ($array as $matiere_id){
|
||||
|
||||
if ($matiere_id === reset($array)){
|
||||
$query->whereHas('matiere', function($q) use ($matiere_id)
|
||||
{
|
||||
$q->where('id', '=', $matiere_id);
|
||||
});
|
||||
}else{
|
||||
$query->orWhereHas('matiere', function($q) use ($matiere_id)
|
||||
{
|
||||
$q->where('id', '=', $matiere_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function scopeTechniqueFilter($query, $array)
|
||||
{
|
||||
|
||||
foreach ($array as $technique_id){
|
||||
|
||||
if ($technique_id === reset($array)){
|
||||
$query->whereHas('technique', function($q) use ($technique_id)
|
||||
{
|
||||
$q->where('id', '=', $technique_id);
|
||||
});
|
||||
}else{
|
||||
$query->orWhereHas('technique', function($q) use ($technique_id)
|
||||
{
|
||||
$q->where('id', '=', $technique_id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function scopeDebutFilter($query, $date)
|
||||
{
|
||||
if ($date == '') return $query;
|
||||
$query->whereHas('datation', function($q) use ($date)
|
||||
{
|
||||
$q->where('debut', '>=', $date);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeFinFilter($query, $date)
|
||||
{
|
||||
if ($date == '') return $query;
|
||||
$query->whereHas('datation', function($q) use ($date)
|
||||
{
|
||||
$q->where('debut', '<=', $date);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -107,11 +107,12 @@
|
||||
|
||||
<!-- PART CHOOSE AND FILL FILTER -->
|
||||
<legend>Recherche avancée</legend><br>
|
||||
<form class="form-horizontal">
|
||||
<form class="form-horizontal" role="form" action="search" method="post">
|
||||
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Auteur</label>
|
||||
<div class="col-sm-10">
|
||||
<select data-placeholder="Choisissez un auteur" class="chosen-select" multiple tabindex="4">
|
||||
<select data-placeholder="Choisissez un auteur" name="auteur[]" class="chosen-select" multiple tabindex="4">
|
||||
<option value=""></option>
|
||||
@foreach ($data['auteur'] as $val)
|
||||
<option value="{{$val -> id}}">{{$val -> nom}}</option>
|
||||
@ -122,7 +123,7 @@
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Désignation</label>
|
||||
<div class="col-sm-10">
|
||||
<select data-placeholder="Choisissez une désignation" class="chosen-select" multiple tabindex="4">
|
||||
<select data-placeholder="Choisissez une désignation" name="designation[]" class="chosen-select" multiple tabindex="4">
|
||||
<option value=""></option>
|
||||
@foreach ($data['designation'] as $val)
|
||||
<option value="{{$val->id}}">{{$val->nom}}</option>
|
||||
@ -133,7 +134,7 @@
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Domaine</label>
|
||||
<div class="col-sm-10">
|
||||
<select data-placeholder="Choisissez un domaine" class="chosen-select" multiple tabindex="4">
|
||||
<select data-placeholder="Choisissez un domaine" name="domaine[]" class="chosen-select" multiple tabindex="4">
|
||||
<option value=""></option>
|
||||
@foreach ($data['domaine'] as $val)
|
||||
<option value="{{$val->id}}">{{$val->nom}}</option>
|
||||
@ -144,7 +145,7 @@
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Matière</label>
|
||||
<div class="col-sm-10">
|
||||
<select data-placeholder="Choisissez une matière" class="chosen-select" multiple tabindex="4">
|
||||
<select data-placeholder="Choisissez une matière" name="matiere[]" class="chosen-select" multiple tabindex="4">
|
||||
<option value=""></option>
|
||||
@foreach ($data['matiere'] as $val)
|
||||
<option value="{{$val->id}}">{{$val->nom}}</option>
|
||||
@ -155,9 +156,9 @@
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Technique</label>
|
||||
<div class="col-sm-10">
|
||||
<select data-placeholder="Choisissez une technique" class="chosen-select" multiple tabindex="4">
|
||||
<select data-placeholder="Choisissez une technique" name="technique[]" class="chosen-select" multiple tabindex="4">
|
||||
<option value=""></option>
|
||||
@foreach ($data['designation'] as $val)
|
||||
@foreach ($data['technique'] as $val)
|
||||
<option value="{{$val->id}}">{{$val->nom}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@ -166,19 +167,19 @@
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Mot clé</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="text" class="form-control" id="exampleInputName2" placeholder="Mot clé">
|
||||
<input type="text" class="form-control" name="motcle" disabled id="exampleInputName2" placeholder="Mot clé">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Date Début</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="text" class="form-control" id="exampleInputName2" placeholder="date début">
|
||||
<div class="col-sm-3">
|
||||
<input type="date" class="form-control" name="debut" id="exampleInputName2" placeholder="date début">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Date Fin</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="text" class="form-control" id="exampleInputName2" placeholder="date fin">
|
||||
<div class="col-sm-3">
|
||||
<input type="date" class="form-control" name="fin" id="exampleInputName2" placeholder="date fin">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user