ldc-dam/app/Models/Sujet.php

118 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2019-05-16 17:20:30 +02:00
<?php
namespace App\Models;
2019-05-16 17:20:30 +02:00
use Illuminate\Database\Eloquent\Model;
class Sujet extends Model
{
2022-04-19 16:07:27 +02:00
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'codeSujet';
/**
* Indicates if the IDs are auto-incrementing.
*
* @var boolean
*/
public $incrementing = false;
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'sujet_dam' => 'bool'
];
// * RELATIONSHIPS
/**
* BelongsToMany users relation
*
* The users that belong to the sujet.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
2022-04-19 16:07:27 +02:00
public function users()
{
return $this->belongsToMany(User::class);
2022-04-19 16:07:27 +02:00
}
2019-05-16 17:20:30 +02:00
/**
* HasMany dossiers relation
*
* Get the dossier for the sujet.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
2022-04-19 16:07:27 +02:00
public function dossiers()
{
return $this->hasMany(Dossier::class);
2022-04-19 16:07:27 +02:00
}
2019-05-22 17:10:16 +02:00
/**
* HasMany variantes relation
*
* Get the variantes for the sujet.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
2022-04-19 16:07:27 +02:00
public function variantes()
{
return $this->hasMany(Variante::class, 'sujet_id', 'codeSujet');
2022-04-19 16:07:27 +02:00
}
/**
* HasMany typeVues relation
*
* Get the typeVue for the sujet.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
2022-04-19 16:07:27 +02:00
public function typeVues()
{
return $this->hasMany(TypeVue::class, 'sujet_id', 'codeSujet');
2022-04-19 16:07:27 +02:00
}
/**
* HasMany media relation
*
* Get the media for the sujet.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function mediaList()
2022-04-19 16:07:27 +02:00
{
return $this->hasMany(Media::class);
2022-04-19 16:07:27 +02:00
}
/**
* BelongsToMany formats relation
*
* The formats that belong to the sujet.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
2022-04-19 16:07:27 +02:00
public function formats()
{
return $this->belongsToMany(Format::class, 'sujet_format', 'sujet_id');
2022-04-19 16:07:27 +02:00
}
2019-07-25 09:43:06 +02:00
/**
* HasMany recherches relation
*
* Get the recherches for the sujet.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
2022-04-19 16:07:27 +02:00
public function recherches()
{
return $this->hasMany(Recherche::class);
2022-04-19 16:07:27 +02:00
}
2019-05-16 17:20:30 +02:00
}