This commit is contained in:
20
api/app/Models/Cadastro/Material/Apresentacao.php
Normal file
20
api/app/Models/Cadastro/Material/Apresentacao.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Apresentacao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_apresentacao';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/Material/LivroRegistro.php
Normal file
20
api/app/Models/Cadastro/Material/LivroRegistro.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LivroRegistro extends Model
|
||||
{
|
||||
protected $table = 'cadastro_livro_registro';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/Material/LivroRegistroTipo.php
Normal file
20
api/app/Models/Cadastro/Material/LivroRegistroTipo.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LivroRegistroTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_livro_registro_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
241
api/app/Models/Cadastro/Material/Material.php
Normal file
241
api/app/Models/Cadastro/Material/Material.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Cadastro\Grupo\Grupo;
|
||||
use App\Models\Farmacia\LivroPagina;
|
||||
use App\Models\Farmacia\ReceitaItem;
|
||||
use App\Models\Almoxarifado\SaidaItem;
|
||||
use App\Models\Cadastro\UnidadeMedida;
|
||||
use App\Enums\Cadastro\Grupo\GrupoTipo;
|
||||
use App\Models\Cadastro\MaterialBnafar;
|
||||
use App\Models\Almoxarifado\EntradaItem;
|
||||
use App\Models\Almoxarifado\ReservaItem;
|
||||
use App\Models\Cadastro\Subgrupo\Subgrupo;
|
||||
use App\Models\Almoxarifado\RequisicaoItem;
|
||||
use App\Models\Integracao\Bnafar\Medicamento;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\Cadastro\Material\Apresentacao;
|
||||
use App\Models\Cadastro\Material\LivroRegistro;
|
||||
use App\Models\Farmacia\AltoCusto\ProcessoItem;
|
||||
use App\Models\Almoxarifado\RequisicaoPermissao;
|
||||
use App\Models\Cadastro\Medicamento\ReceitaTipo;
|
||||
use App\Models\Almoxarifado\ParametrizacaoEstoque;
|
||||
use App\Models\Cadastro\Material\LivroRegistroTipo;
|
||||
use App\Models\Cadastro\Medicamento\ViaAdministracao;
|
||||
use App\Models\Cadastro\Medicamento\FormaFarmaceutica;
|
||||
use App\Models\Almoxarifado\ParametrizacaoDispensacaoMateriais;
|
||||
use App\Models\Almoxarifado\ParametrizacaoPortalDivulgacaoMaterialgrupo;
|
||||
|
||||
class Material extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_material';
|
||||
|
||||
protected $casts = [
|
||||
'is_ativo' => 'boolean',
|
||||
'is_exibir_receita' => 'boolean',
|
||||
'is_exibir_prescricao_interna' => 'boolean',
|
||||
'is_alto_custo' => 'boolean',
|
||||
'is_programa_remedio_em_casa' => 'boolean',
|
||||
'is_acao_judicial' => 'boolean',
|
||||
'is_remume' => 'boolean',
|
||||
'is_medicamento' => 'boolean',
|
||||
'possui_lote' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'descricao',
|
||||
'codigo_material',
|
||||
'apresentacao_id',
|
||||
'quantidade',
|
||||
'grupo_id',
|
||||
'subgrupo_id',
|
||||
'is_ativo',
|
||||
'receita_tipo_id',
|
||||
'livro_registro_id',
|
||||
'livro_registro_tipo_id',
|
||||
'forma_farmaceutica_id',
|
||||
'via_administracao_id',
|
||||
'material_bnafar_id',
|
||||
'is_exibir_receita',
|
||||
'is_exibir_prescricao_interna',
|
||||
'is_alto_custo',
|
||||
'is_programa_remedio_em_casa',
|
||||
'is_acao_judicial',
|
||||
'is_remume',
|
||||
'possui_lote',
|
||||
'apresentacao_unidade_medida_id',
|
||||
'prescricao_unidade_medida_id',
|
||||
'quantidade_gotas_ml',
|
||||
];
|
||||
|
||||
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',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'is_medicamento',
|
||||
];
|
||||
|
||||
public function apresentacao()
|
||||
{
|
||||
return $this->belongsTo(Apresentacao::class);
|
||||
}
|
||||
|
||||
public function apresentacaoUnidadeMedida()
|
||||
{
|
||||
return $this->belongsTo(UnidadeMedida::class);
|
||||
}
|
||||
|
||||
public function prescricaoUnidadeMedida()
|
||||
{
|
||||
return $this->belongsTo(UnidadeMedida::class);
|
||||
}
|
||||
|
||||
public function grupo()
|
||||
{
|
||||
return $this->belongsTo(Grupo::class);
|
||||
}
|
||||
|
||||
public function subgrupo()
|
||||
{
|
||||
return $this->belongsTo(Subgrupo::class);
|
||||
}
|
||||
|
||||
public function receitaTipo()
|
||||
{
|
||||
return $this->belongsTo(ReceitaTipo::class);
|
||||
}
|
||||
|
||||
public function livroRegistro()
|
||||
{
|
||||
return $this->belongsTo(LivroRegistro::class);
|
||||
}
|
||||
|
||||
public function livroRegistroTipo()
|
||||
{
|
||||
return $this->belongsTo(LivroRegistroTipo::class);
|
||||
}
|
||||
|
||||
public function formaFarmaceutica()
|
||||
{
|
||||
return $this->belongsTo(FormaFarmaceutica::class);
|
||||
}
|
||||
|
||||
public function viaAdministracao()
|
||||
{
|
||||
return $this->belongsTo(ViaAdministracao::class);
|
||||
}
|
||||
|
||||
public function materialBnafar()
|
||||
{
|
||||
return $this->belongsTo(MaterialBnafar::class);
|
||||
}
|
||||
|
||||
public function integracaoBnafarMedicamentos()
|
||||
{
|
||||
return $this->belongsToMany(Medicamento::class, 'cadastro_material_integracao_bnafar_medicamento', 'material_id', 'medicamento_id')
|
||||
->using(MaterialIntegracaoBnafarMedicamento::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicaoPermissoes()
|
||||
{
|
||||
return $this->hasMany(RequisicaoPermissao::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicaoItens()
|
||||
{
|
||||
return $this->hasMany(RequisicaoItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoReservaItens()
|
||||
{
|
||||
return $this->hasMany(ReservaItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoEntradaItens()
|
||||
{
|
||||
return $this->hasMany(EntradaItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaItens()
|
||||
{
|
||||
return $this->hasMany(SaidaItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacaoEstoque()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoEstoque::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacaoDispensacao()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoDispensacaoMateriais::class);
|
||||
}
|
||||
|
||||
public function farmaciaLivroPagina()
|
||||
{
|
||||
return $this->hasMany(LivroPagina::class);
|
||||
}
|
||||
|
||||
public function farmaciaReceitaItens()
|
||||
{
|
||||
return $this->hasMany(ReceitaItem::class);
|
||||
}
|
||||
|
||||
public function farmaciaProcessoItens()
|
||||
{
|
||||
return $this->hasMany(ProcessoItem::class);
|
||||
}
|
||||
|
||||
public function parametrizacaoPortalDivulgacaoMaterialgrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoPortalDivulgacaoMaterialgrupo::class);
|
||||
}
|
||||
|
||||
public function getQuantidadeAttribute($value)
|
||||
{
|
||||
return round($value, 2);
|
||||
}
|
||||
|
||||
public function getIsMedicamentoAttribute()
|
||||
{
|
||||
return ($this->grupo->grupo_tipo_id ?? null) === GrupoTipo::MEDICAMENTO;
|
||||
}
|
||||
|
||||
public function getDescricaoCompletaAttribute()
|
||||
{
|
||||
$apresentacaoNome = Str::upper($this->apresentacao->nome);
|
||||
$apresentacaoQuantidade = (int) $this->quantidade;
|
||||
$apresentacaoUnidadeMedida = Str::upper($this->apresentacaoUnidadeMedida->nome ?? '');
|
||||
|
||||
return "{$this->descricao} - {$apresentacaoNome} {$apresentacaoQuantidade} {$apresentacaoUnidadeMedida}";
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'almoxarifadoRequisicaoPermissoes',
|
||||
'almoxarifadoRequisicaoItens',
|
||||
'almoxarifadoReservaItens',
|
||||
'almoxarifadoEntradaItens',
|
||||
'almoxarifadoSaidaItens',
|
||||
'farmaciaLivroPagina',
|
||||
'farmaciaReceitaItens',
|
||||
'farmaciaProcessoItens',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class MaterialIntegracaoBnafarMedicamento extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user