73 lines
1.3 KiB
PHP
73 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Statistique extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $table = 'statistiques';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = 'id';
|
|
/**
|
|
* @var string
|
|
*/
|
|
const CREATED_AT = 'created_at';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'stat_campId',
|
|
'stat_couponId',
|
|
'stat_couponPrinted',
|
|
'date'
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'date' => 'date'
|
|
];
|
|
|
|
/**
|
|
* Perform any actions required after the model boots.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (self $model) {
|
|
$model->date = now()->toDateString();
|
|
});
|
|
}
|
|
|
|
// * RELATIONS
|
|
|
|
/**
|
|
* ArchiveCoupon model relation
|
|
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function campaign()
|
|
{
|
|
return $this->belongsTo(Campagne::class, 'stat_campId', 'camp_id');
|
|
}
|
|
|
|
/**
|
|
* ArchiveCampaign model relation
|
|
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function coupon()
|
|
{
|
|
return $this->belongsTo(Coupon::class, 'stat_couponId', 'coupon_id');
|
|
}
|
|
}
|