2026-05-07 23:31:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Phase extends Model
|
|
|
|
|
{
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'project_id', 'name', 'description', 'order', 'color', 'progress_percent'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function project()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Project::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function layers()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Layer::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function progressUpdates()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(ProgressUpdate::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get latest active layer (most recent upload)
|
|
|
|
|
public function currentLayer()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(Layer::class)->latestOfMany();
|
|
|
|
|
}
|
2026-05-08 01:16:20 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all features across all layers of this phase.
|
|
|
|
|
*/
|
|
|
|
|
public function features()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasManyThrough(Feature::class, Layer::class);
|
|
|
|
|
}
|
2026-05-07 23:31:33 +02:00
|
|
|
}
|