98 lines
1.7 KiB
PHP
98 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Campagne extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
const CREATED_AT = 'camp_createdate';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
const UPDATED_AT = 'camp_updatedate';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
const DELETED_AT = 'camp_deleted_at';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $table = 'campagne';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = 'camp_id';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $dates = ['camp_deleted_at'];
|
|
|
|
|
|
|
|
/**
|
|
* OneToMany
|
|
* Campagne -> Notification
|
|
*/
|
|
public function notifications()
|
|
{
|
|
return $this->hasMany('App\Notification', 'notif_campId', 'camp_id');
|
|
}
|
|
|
|
/**
|
|
* OneToMany
|
|
* Campagne -> Mur
|
|
*/
|
|
public function murs()
|
|
{
|
|
return $this->hasMany('App\Mur', 'mur_campId', 'camp_id');
|
|
}
|
|
|
|
/**
|
|
* OneToMany
|
|
* Campagne -> Panier
|
|
*/
|
|
public function paniers()
|
|
{
|
|
return $this->hasMany('App\Panier', 'panier_campId', 'camp_id');
|
|
}
|
|
|
|
/**
|
|
* ManyToOne
|
|
* Campagne -> Site
|
|
*/
|
|
public function site()
|
|
{
|
|
return $this->belongsTo('App\Site', 'camp_siteId', 'site_id');
|
|
}
|
|
|
|
/**
|
|
* The coupons that belong to the campagne.
|
|
*/
|
|
public function coupons()
|
|
{
|
|
return $this->belongsToMany('App\Coupon', 'campagne_coupon', 'campagne_id', 'coup_id');
|
|
}
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'camp_siteId',
|
|
'camp_name',
|
|
'camp_type',
|
|
'camp_limitedPrinting',
|
|
'camp_published'
|
|
];
|
|
}
|