2026-05-07 23:31:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class InspectionTemplate extends Model
|
|
|
|
|
{
|
2026-06-25 17:26:12 +02:00
|
|
|
protected $fillable = ['name', 'description', 'project_id', 'fields'];
|
2026-05-07 23:31:33 +02:00
|
|
|
|
|
|
|
|
protected $casts = ['fields' => 'array'];
|
|
|
|
|
|
2026-06-25 17:26:12 +02:00
|
|
|
/** Proyecto que la creó (informativo; ya no determina visibilidad). */
|
2026-05-07 23:31:33 +02:00
|
|
|
public function project()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Project::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 17:26:12 +02:00
|
|
|
/** Proyectos a los que está asignada esta plantilla (pivot). */
|
|
|
|
|
public function projects()
|
2026-05-11 14:35:24 +02:00
|
|
|
{
|
2026-06-25 17:26:12 +02:00
|
|
|
return $this->belongsToMany(Project::class, 'inspection_template_project')->withTimestamps();
|
2026-05-11 14:35:24 +02:00
|
|
|
}
|
|
|
|
|
|
2026-05-07 23:31:33 +02:00
|
|
|
public function inspections()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Inspection::class);
|
|
|
|
|
}
|
2026-06-25 17:26:12 +02:00
|
|
|
}
|