2015-03-14 14:36:03 +01:00
|
|
|
<?php namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Oeuvre;
|
|
|
|
use App\Auteur;
|
|
|
|
use App\Referent;
|
|
|
|
use Response;
|
|
|
|
use Input;
|
|
|
|
|
|
|
|
class APIController extends Controller {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
public function refByName($reg = "") {
|
|
|
|
|
|
|
|
if(!empty($reg))
|
2015-03-15 19:38:11 +01:00
|
|
|
$res = Referent::where('nom', 'like', '%'.$reg.'%')->orWhere('prenom', 'like', '%'.$reg.'%')->select(['nom', 'prenom', 'image', 'id'])->get();
|
2015-03-14 14:36:03 +01:00
|
|
|
else
|
2015-03-17 17:22:11 +01:00
|
|
|
$res = Referent::take(5)->select(['nom', 'prenom', 'image', 'id'])->get();
|
2015-03-14 14:36:03 +01:00
|
|
|
return Response::json($res->toArray());
|
|
|
|
}
|
|
|
|
|
2015-03-14 16:11:11 +01:00
|
|
|
|
2015-03-14 14:36:03 +01:00
|
|
|
public function searchOeuvres() {
|
2015-03-14 16:11:11 +01:00
|
|
|
/* $auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
2015-03-14 14:36:03 +01:00
|
|
|
$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'): '';
|
2015-03-14 16:11:11 +01:00
|
|
|
|
|
|
|
$res = Oeuvre::authorFilter($auteurs)
|
|
|
|
->techniqueFilter($techniques)
|
|
|
|
->designationFilter($designations)
|
|
|
|
->domaineFilter($domaines)
|
|
|
|
->matiereFilter($matieres)
|
|
|
|
->debutFilter($debut)
|
|
|
|
->finFilter($fin)
|
|
|
|
->paginate(15);
|
|
|
|
|
|
|
|
return Response::json($res->toArray());
|
2015-03-14 14:36:03 +01:00
|
|
|
*/
|
|
|
|
//::whereIn('technique_id', $techniques)
|
|
|
|
//$res = Oeuvre::paginate(15);
|
|
|
|
//$listeoeuvres = Oeuvre::where('auteur_id', '=', Input::get('auteur'))->simplePaginate(1);
|
|
|
|
|
2015-03-14 16:11:11 +01:00
|
|
|
$auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
2015-03-15 02:23:26 +01:00
|
|
|
$designations = (Input::get('designation')) ? Input::get('designation') : "";
|
2015-03-14 16:11:11 +01:00
|
|
|
$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()): [];
|
2015-03-14 14:36:03 +01:00
|
|
|
|
2015-03-15 02:23:26 +01:00
|
|
|
$listeoeuvres = Oeuvre::auteurFilter($auteurs)
|
2015-03-14 16:11:11 +01:00
|
|
|
->techniqueFilter($techniques)
|
|
|
|
->designationFilter($designations)
|
|
|
|
->domaineFilter($domaines)
|
|
|
|
->matiereFilter($matieres)
|
2015-03-16 14:07:32 +01:00
|
|
|
->paginate(10);
|
2015-03-14 14:36:03 +01:00
|
|
|
|
|
|
|
return view('backend/ref_listeoeuvres',['oeuvres' => $listeoeuvres]);
|
|
|
|
|
|
|
|
//return Response::json($res->toArray());
|
|
|
|
}
|
|
|
|
}
|