This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
ModuleWeb/SRC/app/Http/Controllers/ReferentController.php

124 lines
2.7 KiB
PHP
Raw Normal View History

2015-02-12 19:00:23 +00:00
<?php namespace App\Http\Controllers;
2015-02-20 14:00:09 +00:00
use App\Models\User;
2015-02-17 23:31:21 +00:00
use Input;
2015-02-18 15:49:02 +00:00
use Request;
2015-02-20 14:00:09 +00:00
use App\Models\ListeOeuvre;
use App\Models\AssoListeAOeuvre;
2015-02-24 10:34:35 +00:00
use App\Models\Auteur;
use App\Models\Designation;
use App\Models\Domaine;
use App\Models\Matiere;
use App\Models\Technique;
use Response;
2015-02-18 22:15:18 +00:00
2015-02-16 15:27:16 +00:00
2015-02-12 19:00:23 +00:00
class ReferentController extends Controller {
2015-02-13 10:41:05 +00:00
2015-02-12 19:00:23 +00:00
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
2015-02-12 19:00:23 +00:00
}
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
2015-02-17 14:56:30 +00:00
$me = User::current();
$user = User::all();
2015-02-18 22:15:18 +00:00
2015-02-24 10:34:35 +00:00
$dataSearch = [];
$dataSearch['auteur'] = Auteur::orderBy('nom')->get();
$dataSearch['designation'] = Designation::orderBy('nom')->get();
$dataSearch['domaine'] = Domaine::orderBy('nom')->get();
$dataSearch['matiere'] = Matiere::orderBy('nom')->get();
$dataSearch['technique'] = Technique::orderBy('nom')->get();
//$ListeOeuvre = ListeOeuvre::find(2);
//$ListeOeuvre->oeuvres()->attach([22, 23, 24, 25, 26]);
2015-02-18 22:15:18 +00:00
2015-02-19 14:37:52 +00:00
$listeoeuvres = ListeOeuvre::currentUser()->get();
2015-02-24 10:34:35 +00:00
return view('referent', ['nameRoute' => 'Référent', 'me' => $me, 'listeoeuvres' => $listeoeuvres, 'data' => $dataSearch]);
2015-02-12 19:00:23 +00:00
}
2015-02-17 23:31:21 +00:00
/**
2015-02-18 22:15:18 +00:00
* updateUser an user informations in database.
2015-02-17 23:31:21 +00:00
*
*
*/
public function update()
{
2015-02-18 15:49:02 +00:00
$idUser = Input::get('idUser');
$user = User::find($idUser);
if (Request::hasFile('file'))
{
Request::file('file')->move("./pictures/user_picture/", $idUser);
$user->image = "pictures/user_picture/".$idUser;
}
2015-02-17 23:31:21 +00:00
$user->firstname = Input::get('firstname');
$user->email = Input::get('email');
$user->city = Input::get('city');
$user->lastname = Input::get('lastname');
$user->save();
return redirect('/referent')->with('message_update', 'Referent mis à jour avec succès');
2015-02-18 22:15:18 +00:00
}
/**
* create a new session
*
*/
2015-02-19 14:37:52 +00:00
public function addListeOeuvre()
2015-02-18 22:15:18 +00:00
{
$ListeOeuvre = new ListeOeuvre;
2015-02-19 14:37:52 +00:00
$ListeOeuvre->iduser = Input::get('idUser');
$ListeOeuvre->nom = Input::get('name');
$ListeOeuvre->etat = 0;
2015-02-18 22:15:18 +00:00
$ListeOeuvre->save();
2015-02-19 14:37:52 +00:00
return redirect('/referent');
2015-02-18 22:15:18 +00:00
}
2015-02-19 14:37:52 +00:00
public function showListeOeuvres($id)
2015-02-18 22:15:18 +00:00
{
return Response::json(ListeOeuvre::find($id)->oeuvres->toArray());
2015-02-18 22:15:18 +00:00
}
2015-02-19 14:37:52 +00:00
public function deleteListeOeuvre()
{
$idListeOeuvre = Input::get('idListeOeuvre');
$ListeOeuvre = ListeOeuvre::find($idListeOeuvre);
$ListeOeuvre->delete();
return redirect('/referent');
2015-02-19 14:37:52 +00:00
}
2015-02-17 23:31:21 +00:00
public function setListOeuvres ()
{
$idListeOeuvre = Input::get('idListeOeuvre');
$idconcats = Input::get('oeuvres');
$list_oeuvres_id = explode("-", $idconcats);
$ListeOeuvre = ListeOeuvre::find($idListeOeuvre);
$ListeOeuvre->oeuvres()->detach();
$ListeOeuvre->oeuvres()->attach($list_oeuvres_id);
return Response::json(array());
}
2015-02-12 19:00:23 +00:00
}