- Remove unused FeaturesController (empty stubs, no routes) - Remove ConvertSpatialFile CLI command (unused; service used in LayerManager) - Remove MigrateGeojsonToFeatures CLI command (one-shot migration, not referenced) - Remove .claude/worktrees/ (11 old agent worktrees from June) - Apply Laravel Pint formatting across 219 files (style only, no functional changes) Tests: 101 passing (319 assertions) API routes: unchanged (8 routes intact)
91 lines
2.0 KiB
PHP
91 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\LogsActivity;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Inspection extends Model
|
|
{
|
|
use LogsActivity, SoftDeletes;
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::deleting(function ($inspection) {
|
|
// Cascada: borrar media asociado cuando se elimina la inspección
|
|
$inspection->media()->get()->each->delete();
|
|
});
|
|
}
|
|
|
|
const STATUSES = ['pending', 'in_progress', 'completed', 'approved', 'rejected'];
|
|
|
|
const RESULTS = ['pass', 'fail', 'conditional'];
|
|
|
|
protected $fillable = [
|
|
'project_id', 'layer_id', 'feature_id', 'template_id', 'user_id',
|
|
'data', 'status', 'inspector_user_id', 'completed_at', 'result', 'notes',
|
|
'uuid', 'client_updated_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'data' => 'array',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function layer()
|
|
{
|
|
return $this->belongsTo(Layer::class);
|
|
}
|
|
|
|
public function template()
|
|
{
|
|
return $this->belongsTo(InspectionTemplate::class);
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function inspector()
|
|
{
|
|
return $this->belongsTo(User::class, 'inspector_user_id');
|
|
}
|
|
|
|
public function media()
|
|
{
|
|
return $this->morphMany(Media::class, 'mediable');
|
|
}
|
|
|
|
public function feature()
|
|
{
|
|
return $this->belongsTo(Feature::class, 'feature_id');
|
|
}
|
|
|
|
public function issues()
|
|
{
|
|
return $this->hasMany(Issue::class);
|
|
}
|
|
|
|
public function scopePending($q)
|
|
{
|
|
return $q->where('status', 'pending');
|
|
}
|
|
|
|
public function scopeCompleted($q)
|
|
{
|
|
return $q->where('status', 'completed');
|
|
}
|
|
|
|
public function scopeRejected($q)
|
|
{
|
|
return $q->where('status', 'rejected');
|
|
}
|
|
}
|