database update
This commit is contained in:
parent
2addf1a30b
commit
51fd0b06b9
10
SRC/app/AssoListeAJeu.php
Normal file
10
SRC/app/AssoListeAJeu.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssoListeAJeu extends Model {
|
||||
|
||||
protected $table = 'assolisteajeu';
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
10
SRC/app/AssoListeAOeuvre.php
Normal file
10
SRC/app/AssoListeAOeuvre.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssoListeAOeuvre extends Model {
|
||||
|
||||
protected $table = 'assolisteaoeuvre';
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
@ -3,6 +3,9 @@
|
||||
use App\User;
|
||||
use Input;
|
||||
use Request;
|
||||
use App\ListeOeuvre;
|
||||
use App\AssoListeAOeuvre;
|
||||
|
||||
|
||||
class ReferentController extends Controller {
|
||||
|
||||
@ -26,11 +29,16 @@ class ReferentController extends Controller {
|
||||
{
|
||||
$me = User::current();
|
||||
$user = User::all();
|
||||
return view('referent', ['nameRoute' => '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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 ()
|
||||
|
10
SRC/app/Jeu.php
Normal file
10
SRC/app/Jeu.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Jeu extends Model {
|
||||
|
||||
protected $table = 'jeu';
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
27
SRC/app/ListeOeuvre.php
Normal file
27
SRC/app/ListeOeuvre.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Auth;
|
||||
|
||||
class ListeOeuvre extends Model {
|
||||
|
||||
protected $table = 'listeoeuvre';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function oeuvres()
|
||||
{
|
||||
return $this->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);
|
||||
}
|
||||
}
|
10
SRC/app/Oeuvre.php
Normal file
10
SRC/app/Oeuvre.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Oeuvre extends Model {
|
||||
|
||||
protected $table = 'oeuvre';
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
@ -31,8 +31,8 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
|
||||
public function scopeCurrent($query)
|
||||
{
|
||||
$email = Auth::user()->email;
|
||||
return $query->where('email', $email)->first();
|
||||
$idUser = Auth::user()->id;
|
||||
return $query->where('id', $idUser)->first();
|
||||
}
|
||||
|
||||
public function scopeReferents($query)
|
||||
|
@ -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,
|
||||
|
@ -18,26 +18,12 @@
|
||||
<br><br>
|
||||
<legend>Mes sessions:</legend>
|
||||
<table class="table table-hover">
|
||||
@foreach ($sessions as $session)
|
||||
<tr class="active">
|
||||
<td>Falbala</td>
|
||||
<td>Supprimer</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>biblo</td>
|
||||
<td>Supprimer</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tralala</td>
|
||||
<td>Supprimer</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Redmin</td>
|
||||
<td>Supprimer</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Vive arch linux</td>
|
||||
<td>{{$session->nom}}</td>
|
||||
<td>Supprimer</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user