Files
mgap/app/Models/Control.php
T
2026-09-18 23:35:22 -03:00

35 lines
903 B
PHP

<?php
namespace App\Models;
use App\Traits\LogsAuditoria;
use Illuminate\Database\Eloquent\Model;
class Control extends Model
{
use LogsAuditoria;
protected $table = 'controles';
protected $fillable = ['nombre', 'descripcion', 'estado', 'nivel_de_control', 'fecha_inicio', 'fecha_fin'];
protected $casts = [
'fecha_inicio' => 'datetime',
'fecha_fin' => 'datetime',
];
public function tiposControles()
{
return $this->belongsToMany(TipoControl::class, 'control_tipos_control', 'control_id', 'tipo_control_id')
->withPivot(['fecha_inicio', 'fecha_fin'])
->withTimestamps();
}
public function riesgos()
{
return $this->belongsToMany(Riesgo::class, 'riesgo_control', 'control_id', 'riesgo_id')
->withPivot(['id', 'fecha_identificacion', 'fecha_fin'])
->withTimestamps();
}
}