feat: infrastructure assets management with warranty tracking and EAN lookup integration

This commit is contained in:
jeremy bayse
2026-04-09 21:51:43 +02:00
parent 3544c77bd1
commit b28c56c94c
46 changed files with 2961 additions and 414 deletions

60
app/Models/Licence.php Normal file
View File

@@ -0,0 +1,60 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Licence extends Model
{
use HasFactory;
protected $fillable = [
'contrat_id',
'fournisseur_id',
'commune_id',
'nom',
'cle_licence',
'nombre_sieges_total',
'nombre_sieges_utilises',
'date_acquisition',
'date_expiration',
'type_licence',
'statut',
'notes',
];
protected $casts = [
'date_acquisition' => 'date',
'date_expiration' => 'date',
'cle_licence' => 'encrypted', // Encrypted storage for license keys
];
public function contrat(): BelongsTo
{
return $this->belongsTo(Contrat::class);
}
public function fournisseur(): BelongsTo
{
return $this->belongsTo(Fournisseur::class);
}
public function commune(): BelongsTo
{
return $this->belongsTo(Commune::class);
}
/**
* Get the usage rate as a percentage.
*/
public function getTauxUtilisationAttribute(): float
{
if ($this->nombre_sieges_total <= 0) {
return 0;
}
return round(($this->nombre_sieges_utilises / $this->nombre_sieges_total) * 100, 2);
}
}