2019-01-15 14:17:15 +01:00
|
|
|
<?php
|
|
|
|
|
|
2025-11-12 16:35:16 +01:00
|
|
|
namespace App\Models;
|
2019-01-15 14:17:15 +01:00
|
|
|
|
2025-11-12 16:35:16 +01:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2019-01-15 14:17:15 +01:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Site extends Model
|
|
|
|
|
{
|
2025-11-12 16:35:16 +01:00
|
|
|
use HasFactory;
|
|
|
|
|
|
2019-01-15 14:17:15 +01:00
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2026-10-28 13:23:49 +01:00
|
|
|
|
2019-01-15 14:17:15 +01:00
|
|
|
protected $table = 'site';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2026-10-28 13:23:49 +01:00
|
|
|
|
2019-01-15 14:17:15 +01:00
|
|
|
protected $primaryKey = 'id';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2026-10-28 13:23:49 +01:00
|
|
|
|
2021-04-20 12:40:39 +02:00
|
|
|
protected $keyType = 'string';
|
2019-01-15 14:17:15 +01:00
|
|
|
|
|
|
|
|
/**
|
2025-04-03 09:30:16 +02:00
|
|
|
* @var boolean
|
2019-01-15 14:17:15 +01:00
|
|
|
*/
|
2026-10-28 13:23:49 +01:00
|
|
|
|
2019-01-15 14:17:15 +01:00
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
2026-10-28 13:23:49 +01:00
|
|
|
|
2019-02-22 09:15:03 +01:00
|
|
|
protected $fillable = ['site_nom', 'site_logo', 'site_contact', 'site_rcs', 'site_libelle'];
|
2019-01-15 14:17:15 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* OneToMany
|
|
|
|
|
* Site -> Campagne
|
|
|
|
|
*/
|
|
|
|
|
public function campagnes()
|
|
|
|
|
{
|
2026-10-28 12:27:46 +01:00
|
|
|
return $this->hasMany(\App\Models\Campagne::class, 'camp_siteId', 'site_id');
|
2019-01-15 14:17:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* OneToMany
|
|
|
|
|
* Site -> Contact
|
|
|
|
|
*/
|
|
|
|
|
public function contacts()
|
|
|
|
|
{
|
2026-10-28 12:27:46 +01:00
|
|
|
return $this->hasMany(\App\Models\Contact::class, 'contact_siteId', 'site_id');
|
2019-01-15 14:17:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The users that belong to the site.
|
|
|
|
|
*/
|
|
|
|
|
public function users()
|
|
|
|
|
{
|
2026-10-28 12:27:46 +01:00
|
|
|
return $this->belongsToMany(\App\Models\User::class, 'site_user', 'site_id', 'user_id');
|
2019-01-15 14:17:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-04-03 09:30:16 +02:00
|
|
|
* OneToMany
|
|
|
|
|
* Site -> Coupon
|
|
|
|
|
*/
|
2019-01-15 14:17:15 +01:00
|
|
|
public function coupons()
|
|
|
|
|
{
|
2026-10-28 12:27:46 +01:00
|
|
|
return $this->hasMany(\App\Models\Coupon::class, 'coupon_siteId', 'id');
|
2019-01-15 14:17:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2026-10-28 12:27:46 +01:00
|
|
|
public function __toString(): string
|
2019-01-15 14:17:15 +01:00
|
|
|
{
|
|
|
|
|
return $this->site_id . " : " . $this->site_nom;
|
|
|
|
|
}
|
|
|
|
|
}
|