ldc-mesbr-app/app/Models/Statistique.php

74 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2019-02-20 16:26:32 +01:00
<?php
namespace App\Models;
2019-02-20 16:26:32 +01:00
use Illuminate\Database\Eloquent\Model;
class Statistique extends Model
{
2019-02-27 16:36:53 +01:00
public $timestamps = false;
2021-04-27 17:29:47 +02:00
2019-02-20 16:26:32 +01:00
/**
* @var string
*/
protected $table = 'statistiques';
/**
* @var string
*/
protected $primaryKey = 'id';
/**
* @var string
*/
2019-02-27 16:36:53 +01:00
const CREATED_AT = 'created_at';
2019-02-20 16:26:32 +01:00
/**
* @var array
*/
protected $fillable = [
2019-02-20 16:26:32 +01:00
'stat_campId',
'stat_couponId',
2025-11-04 15:29:03 +01:00
'stat_couponPrinted',
'date'
2019-02-20 16:26:32 +01:00
];
2025-11-04 15:29:03 +01:00
/**
* @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();
});
}
2025-11-04 15:29:03 +01:00
// * 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');
}
2019-02-20 16:26:32 +01:00
}