chore: update document approval workflow and bug fixes
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ContractorManagement\Models;
|
||||
|
||||
use App\Traits\HasPublicIdentifier;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ContractorCertification extends Model
|
||||
{
|
||||
use HasPublicIdentifier;
|
||||
|
||||
protected $fillable = [
|
||||
'contractor_id', 'name', 'certification_number',
|
||||
'issued_date', 'expiry_date', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'issued_date' => 'date',
|
||||
'expiry_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function contractor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Contractor::class);
|
||||
}
|
||||
|
||||
public function getIsExpiringSoonAttribute(): bool
|
||||
{
|
||||
if (!$this->expiry_date) return false;
|
||||
return $this->expiry_date->isBetween(now(), now()->addDays(30));
|
||||
}
|
||||
|
||||
public function getIsExpiredAttribute(): bool
|
||||
{
|
||||
if (!$this->expiry_date) return false;
|
||||
return $this->expiry_date->isPast();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user