Initial commit with contrats and domaines modules
This commit is contained in:
42
app/Models/Domaine.php
Normal file
42
app/Models/Domaine.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user