42 lines
960 B
PHP
42 lines
960 B
PHP
<?php
|
|
|
|
namespace Modules\TimelineScheduling\Models;
|
|
|
|
use App\Traits\HasPublicIdentifier;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Modules\ProjectManagement\Models\Project;
|
|
|
|
class Milestone extends Model
|
|
{
|
|
use HasPublicIdentifier;
|
|
|
|
protected $fillable = [
|
|
'project_id', 'name', 'description', 'target_date', 'achieved_date', 'is_critical',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'target_date' => 'date',
|
|
'achieved_date' => 'date',
|
|
'is_critical' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function project(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function getIsAchievedAttribute(): bool
|
|
{
|
|
return $this->achieved_date !== null;
|
|
}
|
|
|
|
public function getIsOverdueAttribute(): bool
|
|
{
|
|
return !$this->is_achieved && $this->target_date->isPast();
|
|
}
|
|
}
|