ldc-mesbr-app/app/Models/Calendrier.php
2026-10-28 12:27:46 +01:00

59 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Calendrier extends Model
{
/**
* @var string
*/
#[\Override]
protected $table = 'calendrier';
/**
* @var boolean
*/
#[\Override]
public $timestamps = false;
/**
* @var string
*/
#[\Override]
protected $primaryKey = 'calendrier_id';
#[\Override]
protected $dates = ['calendrier_startdate', 'calendrier_enddate'];
/**
* @var array
*/
#[\Override]
protected $fillable = [
'calendrier_startdate',
'calendrier_enddate'
];
/**
* ManyToOne
* Calendrier -> Coupon
*/
public function coupon()
{
return $this->belongsTo(\App\Models\Coupon::class, 'calendrier_couponId');
}
// * METHODS
/**
* Check if the current date is between the calendar publication dates.
*
* @return boolean
*/
public function isPublished(): bool
{
return now()->betweenIncluded($this->calendrier_startdate, $this->calendrier_enddate->endOfDay());
}
}