2019-05-16 17:20:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
2019-09-12 11:08:25 +02:00
|
|
|
namespace App\Models;
|
2019-05-16 17:20:30 +02:00
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Marque extends Model
|
|
|
|
|
{
|
2022-04-19 16:07:27 +02:00
|
|
|
/**
|
2019-05-16 17:20:30 +02:00
|
|
|
* The primary key associated with the table.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2019-07-11 11:45:47 +02:00
|
|
|
protected $primaryKey = 'codMarq';
|
2019-05-16 17:20:30 +02:00
|
|
|
|
2022-04-19 16:07:27 +02:00
|
|
|
/**
|
2022-06-20 14:57:58 +02:00
|
|
|
* Indicates if the IDs are auto-incrementing.
|
|
|
|
|
*
|
|
|
|
|
* @var boolean
|
|
|
|
|
*/
|
|
|
|
|
public $incrementing = false;
|
|
|
|
|
|
|
|
|
|
// * RELATIONSHIPS
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* BelongsToMany users relation
|
|
|
|
|
*
|
2022-04-19 16:07:27 +02:00
|
|
|
* The users that belong to the marque.
|
2022-06-20 14:57:58 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
2022-04-19 16:07:27 +02:00
|
|
|
*/
|
|
|
|
|
public function users()
|
|
|
|
|
{
|
2026-05-13 16:53:56 +02:00
|
|
|
// We have to define foreignPivotKey because primaryKey has been overwritten ...
|
|
|
|
|
return $this->belongsToMany(User::class, foreignPivotKey:'marque_id');
|
2022-04-19 16:07:27 +02:00
|
|
|
}
|
2019-05-16 17:20:30 +02:00
|
|
|
|
2022-06-20 14:57:58 +02:00
|
|
|
/**
|
|
|
|
|
* BelongsToMany dossiers relation
|
|
|
|
|
*
|
|
|
|
|
* The dossier that belong to the marque.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
|
*/
|
2022-04-19 16:07:27 +02:00
|
|
|
public function dossiers()
|
|
|
|
|
{
|
2022-06-20 14:57:58 +02:00
|
|
|
return $this->belongsToMany(Dossier::class, 'marques_dossier', 'marque_id', 'dossier_id');
|
2022-04-19 16:07:27 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-20 14:57:58 +02:00
|
|
|
/**
|
|
|
|
|
* BelongsToMany relation
|
|
|
|
|
*
|
|
|
|
|
* The media that belong to the marques.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
|
*/
|
|
|
|
|
public function mediaList()
|
2022-04-19 16:07:27 +02:00
|
|
|
{
|
2022-06-20 14:57:58 +02:00
|
|
|
return $this->belongsToMany(Media::class);
|
2022-04-19 16:07:27 +02:00
|
|
|
}
|
2019-05-16 17:20:30 +02:00
|
|
|
}
|