86 lines
1.6 KiB
PHP
86 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Cadastro\Localizacao;
|
|
|
|
use App\Models\ExameImagem\Agendamento\Agendamento;
|
|
use App\Models\Intranet\Municipio;
|
|
use App\Models\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Logradouro extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'cadastro_logradouro';
|
|
|
|
protected $fillable = [
|
|
'municipio_id',
|
|
'bairro_id',
|
|
'tipo_id',
|
|
'nome',
|
|
'cep'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'created_at',
|
|
'created_lotacao_id',
|
|
'created_centro_custo_id',
|
|
'updated_at',
|
|
'updated_lotacao_id',
|
|
'updated_centro_custo_id',
|
|
'deleted_at',
|
|
'deleted_lotacao_id',
|
|
'deleted_centro_custo_id',
|
|
'municipio_id',
|
|
'bairro_id',
|
|
'tipo_id'
|
|
];
|
|
|
|
protected $with = [
|
|
'tipo',
|
|
'bairro',
|
|
'municipio'
|
|
];
|
|
|
|
protected $appends = [
|
|
'tipo_nome',
|
|
];
|
|
|
|
public function municipio()
|
|
{
|
|
return $this->belongsTo(Municipio::class);
|
|
}
|
|
|
|
public function bairro()
|
|
{
|
|
return $this->belongsTo(Bairro::class);
|
|
}
|
|
|
|
public function tipo()
|
|
{
|
|
return $this->belongsTo(LogradouroTipo::class);
|
|
}
|
|
|
|
public function enderecos()
|
|
{
|
|
return $this->hasMany(Endereco::class);
|
|
}
|
|
|
|
public function agendamentosExameImagem()
|
|
{
|
|
return $this->hasMany(Agendamento::class);
|
|
}
|
|
|
|
public function getTipoNomeAttribute()
|
|
{
|
|
return "{$this->tipo->descricao} {$this->nome}";
|
|
}
|
|
|
|
public function getIsAllowedToDeleteAttribute()
|
|
{
|
|
return $this->hasNoOne([
|
|
'enderecos'
|
|
]);
|
|
}
|
|
}
|