84 lines
1.5 KiB
PHP
84 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Site extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
|
|
protected $table = 'site';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
|
|
protected $primaryKey = 'id';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
|
|
protected $keyType = 'string';
|
|
|
|
/**
|
|
* @var boolean
|
|
*/
|
|
|
|
public $timestamps = false;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
|
|
protected $fillable = ['site_nom', 'site_logo', 'site_contact', 'site_rcs', 'site_libelle'];
|
|
|
|
/**
|
|
* OneToMany
|
|
* Site -> Campagne
|
|
*/
|
|
public function campagnes()
|
|
{
|
|
return $this->hasMany(\App\Models\Campagne::class, 'camp_siteId', 'site_id');
|
|
}
|
|
|
|
/**
|
|
* OneToMany
|
|
* Site -> Contact
|
|
*/
|
|
public function contacts()
|
|
{
|
|
return $this->hasMany(\App\Models\Contact::class, 'contact_siteId', 'site_id');
|
|
}
|
|
|
|
/**
|
|
* The users that belong to the site.
|
|
*/
|
|
public function users()
|
|
{
|
|
return $this->belongsToMany(\App\Models\User::class, 'site_user', 'site_id', 'user_id');
|
|
}
|
|
|
|
/**
|
|
* OneToMany
|
|
* Site -> Coupon
|
|
*/
|
|
public function coupons()
|
|
{
|
|
return $this->hasMany(\App\Models\Coupon::class, 'coupon_siteId', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function __toString(): string
|
|
{
|
|
return $this->site_id . " : " . $this->site_nom;
|
|
}
|
|
}
|