Ajout des Models
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Activite extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Categorie extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Commentaire extends Model {
|
||||
protected $primaryKey = 'ID_Commentaire';
|
||||
|
||||
public function auteur() {
|
||||
return $this->belongsTo(Utilisateur::class, 'ID_Utilisateur');
|
||||
}
|
||||
|
||||
// Relation récursive pour les réponses aux commentaires [cite: 60, 275]
|
||||
public function reponses() {
|
||||
return $this->hasMany(Commentaire::class, 'ID_Parent_Commentaire');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ressource extends Model {
|
||||
protected $primaryKey = 'ID_Ressource';
|
||||
|
||||
public function type() {
|
||||
return $this->belongsTo(TypeRessource::class, 'ID_Type_Ressource');
|
||||
}
|
||||
|
||||
public function categories() {
|
||||
// Relation Many-to-Many via la table pivot Ressource_Categorie [cite: 175]
|
||||
return $this->belongsToMany(Categorie::class, 'Ressource_Categorie', 'ID_Ressource', 'ID_Categorie');
|
||||
}
|
||||
|
||||
public function createur() {
|
||||
return $this->belongsTo(Utilisateur::class, 'ID_Utilisateur_Createur');
|
||||
}
|
||||
|
||||
public function commentaires() {
|
||||
return $this->hasMany(Commentaire::class, 'ID_Ressource');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TypeRessource extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models; // Déclare que le modèle est dans app/Models
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable; // On importe le "User" de base sous un alias
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class Utilisateur extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
// Indique à Eloquent d'utiliser ta table SQL spécifique [cite: 174, 175]
|
||||
protected $table = 'Utilisateur';
|
||||
|
||||
// Définit la clé primaire personnalisée de ton SQL [cite: 175]
|
||||
protected $primaryKey = 'ID_Utilisateur';
|
||||
|
||||
// Désactive l'auto-incrémentation si nécessaire, ou précise le type
|
||||
public $incrementing = true;
|
||||
protected $keyType = 'int';
|
||||
|
||||
// Liste des champs modifiables (Mass Assignment)
|
||||
protected $fillable = [
|
||||
'Email',
|
||||
'MotDePasse',
|
||||
'Pseudo',
|
||||
'ID_Role',
|
||||
'Statut'
|
||||
];
|
||||
|
||||
// Cache les données sensibles [cite: 99, 176]
|
||||
protected $hidden = [
|
||||
'MotDePasse',
|
||||
];
|
||||
|
||||
// Chiffrement requis par le cahier des charges [cite: 99, 176]
|
||||
protected $casts = [
|
||||
'Email' => 'encrypted',
|
||||
'MotDePasse' => 'hashed',
|
||||
'DateInscription' => 'datetime',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user