Files
dsi-commander/app/Models/Domaine.php

43 lines
906 B
PHP

<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Domaine extends Model
{
use HasFactory;
protected $fillable = [
'nom',
'date_echeance',
'prestataire',
'hebergeur',
];
protected $casts = [
'date_echeance' => 'date',
];
// Un domaine est considéré "proche d'expiration" si l'échéance est dans moins de 30 jours
public function getEstProcheEcheanceAttribute(): bool
{
if (!$this->date_echeance) {
return false;
}
return Carbon::now()->diffInDays($this->date_echeance, false) <= 30;
}
public function getEstEnRetardAttribute(): bool
{
if (!$this->date_echeance) {
return false;
}
return Carbon::now()->isAfter($this->date_echeance);
}
}