Merge branch 'master' of https://github.com/matthieupenchenat81/ModuleWeb
Conflicts: SRC/app/Http/Controllers/ReferentController.php SRC/public/css/game.css SRC/public/css/home.css SRC/resources/views/referent.blade.php SRC/resources/views/referent_games.blade.php
This commit is contained in:
@ -10,7 +10,12 @@ use App\Models\Designation;
|
||||
use App\Models\Domaine;
|
||||
use App\Models\Matiere;
|
||||
use App\Models\Technique;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
use App\Models\Oeuvre;
|
||||
>>>>>>> 407a955444da6207f59c5f05d283275510b2169c
|
||||
use Response;
|
||||
use Illuminate\Pagination\Paginator as Paginator;
|
||||
|
||||
|
||||
class ReferentController extends Controller {
|
||||
@ -42,9 +47,12 @@ class ReferentController extends Controller {
|
||||
$dataSearch['domaine'] = Domaine::orderBy('nom')->get();
|
||||
$dataSearch['matiere'] = Matiere::orderBy('nom')->get();
|
||||
$dataSearch['technique'] = Technique::orderBy('nom')->get();
|
||||
<<<<<<< HEAD
|
||||
|
||||
//$ListeOeuvre = ListeOeuvre::find(2);
|
||||
//$ListeOeuvre->oeuvres()->attach([22, 23, 24, 25, 26]);
|
||||
=======
|
||||
>>>>>>> 407a955444da6207f59c5f05d283275510b2169c
|
||||
|
||||
$listeoeuvres = ListeOeuvre::currentUser()->get();
|
||||
return view('referent', ['nameRoute' => 'Référent', 'me' => $me, 'listeoeuvres' => $listeoeuvres, 'data' => $dataSearch]);
|
||||
@ -120,4 +128,25 @@ class ReferentController extends Controller {
|
||||
return Response::json(array());
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$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)
|
||||
->designationFilter($designations)
|
||||
->domaineFilter($domaines)
|
||||
->matiereFilter($matieres)
|
||||
->debutFilter($debut)
|
||||
->finFilter($fin)
|
||||
->paginate(15);
|
||||
|
||||
return Response::json($res->toArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,97 @@ 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)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('auteurs', function($q) use ($array)
|
||||
{
|
||||
$q->whereIn('id', $array);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeDesignationFilter($query, $array)
|
||||
{
|
||||
if ($array == []) return $query;
|
||||
$query->whereHas('designations', 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);
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user