82 lines
1.7 KiB
PHP
82 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Farmacia;
|
|
|
|
use App\Models\Cadastro\Material\LivroRegistro;
|
|
use App\Models\Cadastro\Material\LivroRegistroTipo;
|
|
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
|
use App\Models\Cadastro\SujeitoAtencao\Usuario;
|
|
use App\Models\Model;
|
|
|
|
class Livro extends Model
|
|
{
|
|
protected $table = 'farmacia_livro';
|
|
|
|
protected $casts = [
|
|
'aberto_em' => 'datetime:d/m/Y',
|
|
'fechado_em' => 'datetime:d/m/Y H:i:s',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'numero',
|
|
'aberto_em',
|
|
'status_id',
|
|
'livro_registro_id',
|
|
'livro_registro_tipo_id',
|
|
'registro',
|
|
'usuario_farmaceutico_id',
|
|
'inscricao_estadual',
|
|
'autoridade_sanitaria',
|
|
'fechado_em',
|
|
'lotacao_fechamento_id',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'created_at',
|
|
'created_lotacao_id',
|
|
'created_centro_custo_id',
|
|
'updated_at',
|
|
'updated_lotacao_id',
|
|
'updated_centro_custo_id',
|
|
];
|
|
|
|
protected $appends = [
|
|
'quantidade_paginas',
|
|
];
|
|
|
|
public function status()
|
|
{
|
|
return $this->belongsTo(LivroStatus::class);
|
|
}
|
|
|
|
public function livroRegistro()
|
|
{
|
|
return $this->belongsTo(LivroRegistro::class);
|
|
}
|
|
|
|
public function livroRegistroTipo()
|
|
{
|
|
return $this->belongsTo(LivroRegistroTipo::class);
|
|
}
|
|
|
|
public function usuarioFarmaceutico()
|
|
{
|
|
return $this->belongsTo(Usuario::class);
|
|
}
|
|
|
|
public function lotacaoFechamento()
|
|
{
|
|
return $this->belongsTo(Lotacao::class);
|
|
}
|
|
|
|
public function paginas()
|
|
{
|
|
return $this->hasMany(LivroPagina::class);
|
|
}
|
|
|
|
public function getQuantidadePaginasAttribute()
|
|
{
|
|
return $this->paginas()->count();
|
|
}
|
|
}
|