135 lines
2.8 KiB
PHP
135 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\BasketContent;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Coupon extends Model
|
|
{
|
|
use SoftDeletes;
|
|
use HasFactory;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
const CREATED_AT = 'coupon_createdate';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
const UPDATED_AT = 'coupon_updatedate';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
const DELETED_AT = 'coupon_deleted_at';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $table = 'coupon';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = 'coupon_id';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'coupon_code',
|
|
'coupon_norme',
|
|
'coupon_gs1code',
|
|
'coupon_name',
|
|
'coupon_value',
|
|
'coupon_enablelimitquantity',
|
|
'coupon_limitquantity',
|
|
'coupon_enablelimitperiod',
|
|
'coupon_limitperiod',
|
|
'coupon_validity',
|
|
'coupon_mindatediffusion',
|
|
'coupon_maxdatediffusion',
|
|
'coupon_maxdatevalidity',
|
|
'coupon_thumbnail1',
|
|
'coupon_thumbnail2',
|
|
'coupon_thumbnail3',
|
|
'coupon_thumbnail4',
|
|
'coupon_image',
|
|
'coupon_published',
|
|
'coupon_logo_image',
|
|
'coupon_rcs',
|
|
'coupon_decoration_image',
|
|
'coupon_validity_text',
|
|
'coupon_site_contact',
|
|
'coupon_legal_mentions',
|
|
'coupon_legal_mentions_splitted',
|
|
'coupon_seuil_alert',
|
|
'coupon_treatment_center'
|
|
];
|
|
|
|
/**
|
|
* OneToMany
|
|
* Coupon -> Calendrier
|
|
*/
|
|
public function calendriers()
|
|
{
|
|
return $this->hasMany('App\Models\Calendrier', 'calendrier_couponId', 'coupon_id');
|
|
}
|
|
|
|
/**
|
|
* OneToMany
|
|
* Coupon -> PanierContent
|
|
*/
|
|
public function panierContents()
|
|
{
|
|
return $this->hasMany('App\Models\PanierContent', 'panier_content_couponId', 'coupon_id');
|
|
}
|
|
|
|
/**
|
|
* OneToMany
|
|
* Coupon -> Mur
|
|
*/
|
|
public function murs()
|
|
{
|
|
return $this->hasMany('App\Models\Mur', 'mur_couponId', 'coupon_id');
|
|
}
|
|
|
|
/**
|
|
* OneToMany
|
|
* Coupon -> Mouvement
|
|
*/
|
|
public function mouvements()
|
|
{
|
|
return $this->hasMany('App\Models\Mouvement', 'mouvement_couponId', 'coupon_id');
|
|
}
|
|
|
|
/**
|
|
* ManyToOne
|
|
* Coupon -> Site
|
|
*/
|
|
public function site()
|
|
{
|
|
return $this->belongsTo('App\Models\Site', 'coupon_siteId');
|
|
}
|
|
|
|
/**
|
|
* The campagnes that belong to the coupon.
|
|
*/
|
|
public function campagnes()
|
|
{
|
|
return $this->belongsToMany('App\Models\Campagne', 'campagne_coupon', 'coup_id', 'campagne_id');
|
|
}
|
|
|
|
/**
|
|
* BasketContent model relation
|
|
* @return HasMany
|
|
*/
|
|
public function basketContents()
|
|
{
|
|
return $this->hasMany(BasketContent::class);
|
|
}
|
|
}
|