ldc-dam/app/Models/Marque.php

62 lines
1.3 KiB
PHP
Raw 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 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
*/
protected $primaryKey = 'codMarq';
2019-05-16 17:20:30 +02:00
2022-04-19 16:07:27 +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.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
2022-04-19 16:07:27 +02:00
*/
public function users()
{
// 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
/**
* 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()
{
return $this->belongsToMany(Dossier::class, 'marques_dossier', 'marque_id', 'dossier_id');
2022-04-19 16:07:27 +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
{
return $this->belongsToMany(Media::class);
2022-04-19 16:07:27 +02:00
}
2019-05-16 17:20:30 +02:00
}