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

54 lines
1,011 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Calendrier extends Model
{
/**
* @var string
*/
protected $table = 'calendrier';
/**
* @var boolean
*/
public $timestamps = false;
/**
* @var string
*/
protected $primaryKey = 'calendrier_id';
protected $dates = ['calendrier_startdate', 'calendrier_enddate'];
/**
* @var array
*/
protected $fillable = [
'calendrier_startdate',
'calendrier_enddate'
];
/**
* ManyToOne
* Calendrier -> Coupon
*/
public function coupon()
{
return $this->belongsTo('App\Models\Coupon', '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());
}
}