belongs_to(Direccion::class, 'direccion')->findOne(); } public function tipo() { return $this->belongs_to(TipoAgente::class, 'tipo')->findOne(); } public function tipos(int $tipo = 0) { if ($tipo == 0) { return $this->hasMany(AgenteTipo::class, 'agente')->findMany(); } return $this->hasMany(AgenteTipo::class, 'agente')->where('tipo', $tipo)->findOne(); } } ?>