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

55 lines
1,011 B
PHP
Raw Permalink Normal View History

2019-01-15 14:17:15 +01:00
<?php
namespace App\Models;
2019-01-15 14:17:15 +01:00
use Illuminate\Database\Eloquent\Model;
class Calendrier extends Model
{
/**
* @var string
*/
protected $table = 'calendrier';
/**
2025-04-03 09:30:16 +02:00
* @var boolean
2019-01-15 14:17:15 +01:00
*/
public $timestamps = false;
/**
* @var string
*/
protected $primaryKey = 'calendrier_id';
protected $dates = ['calendrier_startdate', 'calendrier_enddate'];
2021-04-27 17:29:47 +02:00
2019-01-15 14:17:15 +01:00
/**
* @var array
*/
protected $fillable = [
'calendrier_startdate',
'calendrier_enddate'
];
/**
* ManyToOne
* Calendrier -> Coupon
*/
public function coupon()
{
return $this->belongsTo('App\Models\Coupon', 'calendrier_couponId');
2019-01-15 14:17:15 +01:00
}
// * 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());
}
2019-01-15 14:17:15 +01:00
}