diff --git a/SRC/app/AssoListeAJeu.php b/SRC/app/AssoListeAJeu.php new file mode 100644 index 0000000..888e7c8 --- /dev/null +++ b/SRC/app/AssoListeAJeu.php @@ -0,0 +1,10 @@ + 'Référent', 'me' => $me]); + + // List Oeuvre of one user + $sessions = ListeOeuvre::currentUser()->get(); + echo $sessions[0]->oeuvres()->get(); + + //return view('referent', ['nameRoute' => 'Référent', 'me' => $me, 'sessions' => $sessions]); } /** - * updateUser an user in database. + * updateUser an user informations in database. * * */ @@ -53,6 +61,44 @@ class ReferentController extends Controller { $user->save(); return redirect('/referent')->with('message_update', 'Referent mis à jour avec succès'); - } + } + + /** + * create a new session + * + */ + public function addSession() + { + // TODO + $ListeOeuvre = new ListeOeuvre; + $ListeOeuvre->idusers = 2; + $ListeOeuvre->nom = "Linux"; + $ListeOeuvre->etat = 1; + $ListeOeuvre->save(); + + $assolistaoeuvre = new AssoListeAOeuvre; + $assolistaoeuvre->liste_oeuvre_id = 1; + $assolistaoeuvre->oeuvre_id = 1; + $assolistaoeuvre->save(); + + $assolistaoeuvre2 = new AssoListeAOeuvre; + $assolistaoeuvre2->liste_oeuvre_id = 1; + $assolistaoeuvre2->oeuvre_id = 2; + $assolistaoeuvre2->save(); + } + + + /** + * get all user sessions + * + */ + private function getSessions() + { + // TODO + } + + + + } diff --git a/SRC/app/Http/routes.php b/SRC/app/Http/routes.php index 995f90a..8861b9e 100755 --- a/SRC/app/Http/routes.php +++ b/SRC/app/Http/routes.php @@ -28,6 +28,8 @@ Route::group(['middleware' => 'auth'], function () Route::get('referent', 'ReferentController@index'); Route::get('logout', 'LoginController@logout'); Route::post('update', 'ReferentController@update'); + + Route::post('addSession', 'ReferentController@addSession'); }); Route::group(['middleware' => 'admin'], function () diff --git a/SRC/app/Jeu.php b/SRC/app/Jeu.php new file mode 100644 index 0000000..e365a2b --- /dev/null +++ b/SRC/app/Jeu.php @@ -0,0 +1,10 @@ +belongsToMany('App\Oeuvre', 'assolisteaoeuvre'); + } + + public function jeux() + { + return $this->belongsToMany('App\Jeu', 'assolisteajeu'); + } + + public function scopeCurrentUser($query) + { + $idUser = Auth::user()->id; + return $query->where('idusers', $idUser); + } +} diff --git a/SRC/app/Oeuvre.php b/SRC/app/Oeuvre.php new file mode 100644 index 0000000..ac09b01 --- /dev/null +++ b/SRC/app/Oeuvre.php @@ -0,0 +1,10 @@ +email; - return $query->where('email', $email)->first(); + $idUser = Auth::user()->id; + return $query->where('id', $idUser)->first(); } public function scopeReferents($query) diff --git a/SRC/init/table.sql b/SRC/init/table.sql index fab9dd5..27a9788 100644 --- a/SRC/init/table.sql +++ b/SRC/init/table.sql @@ -106,23 +106,22 @@ CREATE TABLE oeuvre ( ); CREATE TABLE assodesignationaoeuvre ( - idoeuvre INT NOT NULL, - iddesignation INT NOT NULL, - PRIMARY KEY (iddesignation,idoeuvre), - FOREIGN KEY (iddesignation) REFERENCES designation(iddesignation), - FOREIGN KEY (idoeuvre) REFERENCES oeuvre(idoeuvre) + oeuvre_id INT NOT NULL, + designation_id INT NOT NULL, + PRIMARY KEY (designation_id,oeuvre_id), + FOREIGN KEY (designation_id) REFERENCES designation(iddesignation), + FOREIGN KEY (oeuvre_id) REFERENCES oeuvre(idoeuvre) ); CREATE TABLE assoauteuraoeuvre ( - idoeuvre INT NOT NULL, - idauteur INT NOT NULL, - PRIMARY KEY (idauteur,idoeuvre), - FOREIGN KEY (idauteur) REFERENCES auteur(idauteur), - FOREIGN KEY (idoeuvre) REFERENCES oeuvre(idoeuvre) + oeuvre_id INT NOT NULL, + auteur_id INT NOT NULL, + PRIMARY KEY (auteur_id,oeuvre_id), + FOREIGN KEY (auteur_id) REFERENCES auteur(idauteur), + FOREIGN KEY (oeuvre_id) REFERENCES oeuvre(idoeuvre) ); - CREATE TABLE listeoeuvre ( idlisteoeuvre INT NOT NULL AUTO_INCREMENT, idusers INT NOT NULL, @@ -135,23 +134,21 @@ CREATE TABLE listeoeuvre ( ); CREATE TABLE assolisteaoeuvre ( - idlisteoeuvre INT NOT NULL, - idoeuvre INT NOT NULL, - PRIMARY KEY (idlisteoeuvre,idoeuvre), - FOREIGN KEY (idlisteoeuvre) REFERENCES listeoeuvre(idlisteoeuvre), - FOREIGN KEY (idoeuvre) REFERENCES oeuvre(idoeuvre) + liste_oeuvre_id INT NOT NULL, + oeuvre_id INT NOT NULL, + PRIMARY KEY (liste_oeuvre_id,oeuvre_id), + FOREIGN KEY (liste_oeuvre_id) REFERENCES listeoeuvre(idlisteoeuvre), + FOREIGN KEY (oeuvre_id) REFERENCES oeuvre(idoeuvre) ); CREATE TABLE assolisteajeu ( - idlisteoeuvre INT NOT NULL, - idjeu INT NOT NULL, - PRIMARY KEY (idlisteoeuvre,idjeu), - FOREIGN KEY (idlisteoeuvre) REFERENCES listeoeuvre(idlisteoeuvre), - FOREIGN KEY (idjeu) REFERENCES jeu(idjeu) + liste_oeuvre_id INT NOT NULL, + jeu_id INT NOT NULL, + PRIMARY KEY (liste_oeuvre_id,jeu_id), + FOREIGN KEY (liste_oeuvre_id) REFERENCES listeoeuvre(idlisteoeuvre), + FOREIGN KEY (jeu_id) REFERENCES jeu(idjeu) ); - - CREATE TABLE description ( iddescription INT NOT NULL AUTO_INCREMENT, idoeuvre INT NOT NULL, diff --git a/SRC/resources/views/referent.blade.php b/SRC/resources/views/referent.blade.php index 1433150..c9c4e9f 100755 --- a/SRC/resources/views/referent.blade.php +++ b/SRC/resources/views/referent.blade.php @@ -18,26 +18,12 @@

Mes sessions: + @foreach ($sessions as $session) - - - - - - - - - - - - - - - - - + + @endforeach
FalbalaSupprimer
bibloSupprimer
TralalaSupprimer
RedminSupprimer
Vive arch linux{{$session->nom}} Supprimer