- Add Task model with subtasks, priorities, status transitions, dates, hours - Add Comment polymorphic model for tasks/issues/projects - Livewire components: TaskManager (list+filters), TaskForm (modal), TaskDetail, TaskKanban (drag&drop), TaskCalendar (FullCalendar) - TaskPolicy with permissions (view/create/edit/delete/assign/manage all) - Notifications: assigned, status change, overdue, comment added - Daily overdue notification job scheduled - Dashboard widget unifies IssueTask + Task - i18n: en/es/fr/ru (393 keys each) - Routes, navigation, offline sync support - 101 tests passing, Pint compliant on new files
74 lines
1.5 KiB
PHP
74 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Phase extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'project_id', 'name', 'description', 'order', 'color', 'progress_percent',
|
|
'planned_start', 'planned_end', 'actual_start', 'actual_end',
|
|
];
|
|
|
|
protected $casts = [
|
|
'planned_start' => 'date',
|
|
'planned_end' => 'date',
|
|
'actual_start' => 'date',
|
|
'actual_end' => 'date',
|
|
];
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function layers()
|
|
{
|
|
return $this->hasMany(Layer::class);
|
|
}
|
|
|
|
public function progressUpdates()
|
|
{
|
|
return $this->hasMany(ProgressUpdate::class);
|
|
}
|
|
|
|
public function currentLayer()
|
|
{
|
|
return $this->hasOne(Layer::class)->latestOfMany();
|
|
}
|
|
|
|
public function features()
|
|
{
|
|
return $this->hasManyThrough(Feature::class, Layer::class);
|
|
}
|
|
|
|
public function media()
|
|
{
|
|
return $this->morphMany(Media::class, 'mediable');
|
|
}
|
|
|
|
public function images()
|
|
{
|
|
return $this->morphMany(Media::class, 'mediable')->where('category', 'image');
|
|
}
|
|
|
|
public function tasks()
|
|
{
|
|
return $this->hasMany(Task::class);
|
|
}
|
|
|
|
public function getDeviationDaysAttribute(): ?int
|
|
{
|
|
if (! $this->planned_end) {
|
|
return null;
|
|
}
|
|
$end = $this->actual_end ?? now();
|
|
|
|
return $this->planned_end->diffInDays($end, false);
|
|
}
|
|
}
|