Crie o model NFE
para criar o model NFE use o comando: php artisan make:model NFE -m
adicione os seguintes campos:
Schema::create('nves', function (Blueprint $table) {
$table->id();
$table->bigInteger('status_id')->nullable()->unsigned();
$table->foreign('status_id')->references('id')->on('statuses');
$table->bigInteger('natureza_operacao_id')->nullable()->unsigned();
$table->foreign('natureza_operacao_id')->references('id')->on('natureza_operacaos');
$table->string('chave',60)->nullable();
$table->string('recibo',40)->nullable();
$table->string('protocolo',40)->nullable();
$table->integer('sequencia_cce')->nullable();
$table->string('cUF',10);
$table->string('cNF',8)->nullable();
$table->string('nNF',15)->nullable();
$table->string('natOp',80);
$table->string('modelo',2)->nullable();
$table->string('serie',3)->nullable();
$table->string('dhEmi',40)->nullable();
$table->string('dhSaiEnt',40)->nullable();
$table->integer('tpNF')->nullable();
$table->integer('idDest')->nullable();
$table->integer('cMunFG')->nullable();
$table->integer('tpImp')->nullable();
$table->integer('tpEmis')->nullable();
$table->integer('tpAmb')->nullable();
$table->integer('finNFe')->nullable();
$table->integer('indFinal')->nullable();
$table->integer('indPres')->nullable();
$table->string('indIntermed',1)->nullable();
$table->string('cnpjIntermed',15)->nullable();
$table->string('idCadIntTran',80)->nullable();
$table->integer('procEmi')->nullable();
$table->string('verProc',20)->nullable();
$table->string('dhCont',20)->nullable();
$table->text('xJust')->nullable();
$table->decimal('vProd_liquido',10,2)->nullable();
$table->decimal('desconto_itens',10,2)->nullable();
$table->decimal('desconto_nota',10,2)->nullable();
$table->decimal('vBC',10,2)->nullable();
$table->decimal('vICMS',10,2)->nullable();
$table->decimal('vICMSDeson',10,2)->nullable();
$table->decimal('vFCP',10,2)->nullable();
$table->decimal('vBCST',10,2)->nullable();
$table->decimal('vST',10,2)->nullable();
$table->decimal('vFCPST',10,2)->nullable();
$table->decimal('vFCPSTRet',10,2)->nullable();
$table->decimal('vProd',10,2)->nullable();
$table->decimal('vFrete',10,2)->nullable();
$table->decimal('vSeg',10,2)->nullable();
$table->decimal('vDesc',10,2)->nullable();
$table->decimal('vII',10,2)->nullable();
$table->decimal('vIPI',10,2)->nullable();
$table->decimal('vIPIDevol',10,2)->nullable();
$table->decimal('vPIS',10,2)->nullable();
$table->decimal('vCOFINS',10,2)->nullable();
$table->decimal('vOutro',10,2)->nullable();
$table->decimal('vNF',10,2)->nullable();
$table->decimal('vTotTrib',10,2)->nullable();
$table->decimal('vOrig',10,2)->nullable();
$table->decimal('vLiq',10,2)->nullable();
$table->decimal('vTroco',10,2)->nullable();
$table->decimal('vRetPIS',10,2)->nullable();
$table->decimal('vRetCOFINS',10,2)->nullable();
$table->decimal('vRetCSLL',10,2)->nullable();
$table->decimal('vBCIRRF',10,2)->nullable();
$table->decimal('vIRRF',10,2)->nullable();
$table->decimal('vBCRetPrev',10,2)->nullable();
$table->decimal('vRetPrev',10,2)->nullable();
$table->decimal('ret_tran_vserv',10,2)->nullable();
$table->decimal('ret_tran_vbc',10,2)->nullable();
$table->decimal('ret_tran_pcims',10,2)->nullable();
$table->decimal('ret_tran_cfop',10,2)->nullable();
$table->decimal('ret_tran_uf',10,2)->nullable();
$table->decimal('ret_tran_cmunfg',10,2)->nullable();
$table->decimal('estadual',10,2)->nullable();
$table->decimal('municipal',10,2)->nullable();
$table->decimal('nacionalfederal',10,2)->nullable();
$table->decimal('importadosfederal',10,2)->nullable();
$table->string('em_xNome',60)->nullable();
$table->string('em_xFant',60)->nullable();
$table->string('em_IE',14)->nullable();
$table->string('em_IEST',14)->nullable();
$table->string('em_IM',15)->nullable();
$table->string('em_CNAE',7)->nullable();
$table->integer('em_CRT')->nullable();
$table->string('em_CNPJ',14)->nullable();
$table->string('em_CPF',30)->nullable();
$table->string('em_xLgr',60)->nullable();
$table->string('em_nro',60)->nullable();
$table->string('em_xCpl',60)->nullable();
$table->string('em_xBairro',60)->nullable();
$table->string('em_cMun',10)->nullable();
$table->string('em_xMun',60)->nullable();
$table->string('em_UF',2)->nullable();
$table->string('em_CEP',8)->nullable();
$table->string('em_cPais',11)->nullable();
$table->string('em_xPais',60)->nullable();
$table->string('em_fone',14)->nullable();
$table->string('em_EMAIL',60)->nullable();
$table->string('em_SUFRAMA',40)->nullable();
$table->decimal('em_pCredSN',10,2)->nullable();
//Transporte
$table->string('modFrete',2)->nullable();
$table->string('transp_xNome',100)->nullable();
$table->string('transp_IE',20)->nullable();
$table->string('transp_xEnder',80)->nullable();
$table->string('transp_xMun',80)->nullable();
$table->string('transp_UF',2)->nullable();
$table->string('transp_CNPJ',20)->nullable();
$table->string('transp_CPF',20)->nullable();
$table->decimal('transp_ret_vServ',10,2)->nullable();
$table->decimal('transp_ret_vBCRet',10,2)->nullable();
$table->decimal('transp_ret_pICMSRet',10,2)->nullable();
$table->decimal('transp_ret_vICMSRet',10,2)->nullable();
$table->string('transp_ret_CFOP',5)->nullable();
$table->string('transp_ret_cMunFG',10)->nullable();
$table->string('transp_veic_placa',20)->nullable();
$table->string('transp_veic_UF',5)->nullable();
$table->string('transp_veic_RNTC',20)->nullable();
$table->string('transp_reboque_placa',20)->nullable();
$table->string('transp_reboque_UF',5)->nullable();
$table->string('transp_reboque_RNTC',20)->nullable();
$table->string('transp_vagao',10)->nullable();
$table->string('transp_balsa',10)->nullable();
$table->integer('qVol')->nullable();
$table->string('esp',40)->nullable();
$table->string('marca',40)->nullable();
$table->string('nVol',40)->nullable();
$table->decimal('pesoL',10,5)->nullable();
$table->decimal('pesoB',10,2)->nullable();
$table->string('nLacre',40)->nullable();
$table->string('resp_CNPJ',50)->nullable();
$table->string('resp_xContato',50)->nullable();
$table->string('resp_email',50)->nullable();
$table->string('resp_fone',50)->nullable();
$table->string('resp_CSRT',50)->nullable();
$table->string('resp_idCSRT',50)->nullable();
$table->string('nFat',20)->nullable();
$table->text('infAdFisco')->nullable();
$table->text('infCpl')->nullable();
$table->timestamps();
});
Configure os fillables do Model NFE
protected $fillable =[
'venda_id',
'status_id',
'livre',
'natureza_operacao_id',
'tipo_nfe_id',
'nota_referencia_id',
'chave',
'recibo',
'importado',
'protocolo',
'cUF',
'cNF',
'natOp',
'modelo',
'serie',
'nNF',
'cDV',
'sequencia_cce',
'dhEmi',
'dhSaiEnt',
'tpNF',
'idDest',
'cMunFG',
'tpImp',
'tpEmis',
'tpAmb',
'finNFe',
'indFinal',
'indPres',
'indIntermed',
'cnpjIntermed',
'idCadIntTran',
'tipo_nota_referenciada',
'ref_NFe',
'ref_ano_mes',
'ref_num_nf',
'ref_serie',
'procEmi',
'verProc',
'dhCont',
'xJust',
'vBC',
'vICMS',
'vICMSDeson',
'vFCP',
'vBCST',
'vST',
'vFCPST',
'vFCPSTRet',
'vProd',
'vProd_liquido',
'vFrete',
'vSeg',
'desconto_itens',
'desconto_nota',
'vDesc',
'vII',
'vIPI',
'vIPIDevol',
'vPIS',
'vCOFINS',
'vOutro',
'vNF',
'vTotTrib',
'vOrig',
'vLiq',
'nFat',
'vRetPIS',
'vRetCOFINS',
'vRetCSLL',
'vBCIRRF',
'vIRRF',
'vBCRetPrev',
'vRetPrev',
'em_xNome',
'em_xFant',
'em_IE',
'em_IEST',
'em_IM',
'em_CNAE',
'em_CRT',
'em_CNPJ',
'em_CPF',
'em_xLgr',
'em_nro',
'em_xCpl',
'em_xBairro',
'em_cMun',
'em_xMun',
'em_UF',
'em_CEP',
'em_cPais',
'em_xPais',
'em_fone',
'em_EMAIL',
'em_SUFRAMA',
'atualizacao',
'modFrete',
'tPag',
'vPag',
'CNPJ_pag',
'tBand',
'cAut',
'tpIntegra',
'indPag',
'infAdFisco',
'infCpl',
'empresa_id',
'resp_CNPJ',
'resp_xContato',
'resp_email',
'resp_fone',
'resp_CSRT',
'resp_idCSRT',
'transp_xNome',
'transp_IE',
'transp_xEnder',
'transp_xMun',
'transp_UF',
'transp_CNPJ',
'transp_placa',
'transp_vagao',
'transp_balsa',
'transp_placa',
'UF_placa',
'estadual','municipal','nacionalfederal','importadosfederal',
'transp_ret_vServ', 'transp_ret_vBCRet','transp_ret_pICMSRet','transp_ret_vICMSRet','transp_ret_CFOP','transp_ret_cMunFG',
'transp_veic_placa','transp_veic_UF','transp_veic_RNTC',
'transp_reboque_placa','transp_reboque_UF','transp_reboque_RNTC',
'RNTC',
'qVol',
'esp',
'marca',
'nVol',
'pesoL',
'pesoB',
'nLacre'
];
faça o relacionamento da tabela produto com as tabelas:
- NaturezaOperacao
public function naturezaOperacao(){
return $this->belongsTo(NaturezaOperacao::class, 'natureza_operacao_id');
}
Crie o model NfeDestinatario
para criar o model NfeDestinatario use o comando: php artisan make:model NfeDestinatario -m
adicione os seguintes campos:
Schema::create('nfe_destinatarios', function (Blueprint $table) {
$table->id();
$table->bigInteger('nfe_id')->unique()->unsigned();
$table->foreign('nfe_id')->references('id')->on('nves');
$table->string('dest_xNome',60)->nullable();
$table->string('dest_IE',14)->nullable();
$table->string('dest_indIEDest',20)->nullable();
$table->string('dest_ISUF',20)->nullable();
$table->string('dest_IM',15)->nullable();
$table->string('dest_email',60)->nullable();
$table->string('dest_CNPJ',14)->nullable();
$table->string('dest_CPF',15)->nullable();
$table->string('dest_idEstrangeiro',20)->nullable();
$table->string('dest_xLgr',60)->nullable();
$table->string('dest_nro',60)->nullable();
$table->string('dest_xCpl',60)->nullable();
$table->string('dest_xBairro',60)->nullable();
$table->string('dest_cMun',20)->nullable();
$table->string('dest_xMun',60)->nullable();
$table->string('dest_UF',2)->nullable();
$table->string('dest_CEP',8)->nullable();
$table->string('dest_cPais',20)->nullable();
$table->string('dest_xPais',60)->nullable();
$table->string('dest_fone',14)->nullable();
$table->timestamps();
});
Configure os fillables do Model NfeDestinatario
protected $fillable =[
'nfe_id',
'dest_xNome',
'dest_IE',
'dest_indIEDest',
'dest_ISUF',
'dest_IM',
'dest_email',
'dest_CNPJ',
'dest_CPF',
'dest_idEstrangeiro',
'dest_xLgr',
'dest_nro',
'dest_xCpl',
'dest_xBairro',
'dest_cMun',
'dest_xMun',
'dest_UF',
'dest_CEP',
'dest_cPais',
'dest_xPais',
'dest_fone'];
}
Crie o model NfeItem
para criar o model NfeItem use o comando: php artisan make:model NfeItem -m
adicione os seguintes campos:
Schema::create('nfe_items', function (Blueprint $table) {
$table->id();
$table->bigInteger('nfe_id')->unsigned();
$table->foreign('nfe_id')->references('id')->on('nves');
$table->bigInteger('produto_id')->unsigned()->nullable();
$table->foreign('produto_id')->references('id')->on('produtos');
$table->integer('numero_item')->nullable();
//Produto
$table->string('cProd',60)->nullable();
$table->string('cEAN',14)->nullable();
$table->string('xProd',120)->nullable();
$table->string('NCM',20)->nullable();
$table->string('CEST',20)->nullable();
$table->string('indEscala',1)->nullable();
$table->string('cBenef',20)->nullable();
$table->string('NVE',20)->nullable();
$table->string('EXTIPI',15)->nullable();
$table->string('CFOP',10)->nullable();
$table->string('uCom',6)->nullable();
$table->decimal('qCom',10,2)->nullable();
$table->decimal('vUnCom',10,2)->nullable();
$table->decimal('vProd',10,2)->nullable();
$table->string('cEANTrib',14)->nullable();
$table->string('uTrib',6)->nullable();
$table->decimal('qTrib',10,2)->nullable();
$table->decimal('vUnTrib',10,2)->nullable();
$table->decimal('proporcao',10,2)->nullable();
$table->decimal('vFrete',10,2)->nullable();
$table->decimal('vSeg',10,2)->nullable();
$table->decimal('desconto_item',10,2)->nullable();
$table->decimal('desconto_rateio',10,2)->nullable();
$table->decimal('vDesc',10,2)->nullable();
$table->decimal('vOutro',10,2)->nullable();
$table->integer('indTot')->nullable();
$table->string('xPed',15)->nullable();
$table->integer('nItemPed')->nullable();
$table->string('nFCI',36)->nullable();
//IPI
$table->string('cstIPI',40)->nullable();
$table->string('clEnq',40)->nullable();
$table->string('CNPJProd',40)->nullable();
$table->string('cSelo',40)->nullable();
$table->string('qSelo',40)->nullable();
$table->string('cEnq',40)->nullable();
$table->decimal('vIPI',10,2)->nullable();
$table->decimal('vBCIPI',10,2)->nullable();
$table->decimal('pIPI',10,2)->nullable();
$table->decimal('qUnidIPI',10,2)->nullable();
$table->decimal('vUnidIPI',10,2)->nullable();
$table->integer('tipo_calc_ipi')->nullable();
//COfins
$table->string('cstCOFINS',40)->nullable();
$table->decimal('pCOFINS',10,2)->nullable();
$table->decimal('qBCProdConfis',10,2)->nullable();
$table->integer('tipo_calc_cofins')->nullable();
$table->decimal('vAliqProd_cofins',10,2)->nullable();
$table->decimal('vBCCOFINS',10,2)->nullable();
$table->decimal('vCOFINS',10,2)->nullable();
$table->integer('tipo_calc_cofinsst')->nullable();
$table->decimal('pCOFINSST',10,2)->nullable();
$table->decimal('vBCCOFINSST',10,2)->nullable();
$table->decimal('vCOFINSST',10,2)->nullable();
$table->decimal('qBCProdConfisST',10,2)->nullable();
$table->decimal('vAliqProd_cofinsst',10,2)->nullable();
//Pis
$table->string('cstPIS',40)->nullable();
$table->integer('tipo_calc_pis')->nullable();
$table->decimal('vBCPIS',10,2)->nullable();
$table->decimal('pPIS',10,2)->nullable();
$table->decimal('vPIS',10,2)->nullable();
$table->decimal('qBCProdPis',10,2)->nullable();
$table->decimal('qBCProdPisST',10,2)->nullable();
$table->decimal('vBCPISST',10,2)->nullable();
$table->decimal('vAliqProd_pis',10,2)->nullable();
$table->integer('tipo_calc_pisst')->nullable();
$table->decimal('pPISST',10,2)->nullable();
$table->decimal('vPISST',10,2)->nullable();
$table->decimal('vAliqProd_pisst',10,2)->nullable();
$table->string('insere_ipi_na_base',5)->nullable();
//ICMS
$table->string('orig',5)->nullable();
$table->string('cstICMS',40)->nullable();
$table->string('modBC',10)->nullable();
$table->decimal('vBCICMS',10,2)->nullable();
$table->decimal('vICMSTRet',10,2)->nullable();
$table->decimal('pICMS',10,2)->nullable();
$table->decimal('vICMS',10,2)->nullable();
$table->decimal('pFCP',10,2)->nullable();
$table->decimal('vFCP',10,2)->nullable();
$table->decimal('vBCFCP',10,2)->nullable();
$table->decimal('pMVAST',10,2)->nullable();
$table->decimal('pRedBCST',10,2)->nullable();
$table->decimal('vBCST',10,2)->nullable();
$table->decimal('pICMSST',10,2)->nullable();
$table->decimal('vICMSST',10,2)->nullable();
$table->decimal('vST',10,2)->nullable();
$table->decimal('vBCFCPST',10,2)->nullable();
$table->decimal('pFCPST',10,2)->nullable();
$table->decimal('vFCPST',10,2)->nullable();
$table->decimal('vICMSDeson',10,2)->nullable();
$table->integer('motDesICMS')->nullable();
$table->decimal('pRedBC',10,2)->nullable();
$table->decimal('vICMSOp',10,2)->nullable();
$table->decimal('pDif',10,2)->nullable();
$table->decimal('vICMSDif',10,2)->nullable();
$table->decimal('vBCSTRet',10,2)->nullable();
$table->decimal('pST',10,2)->nullable();
$table->decimal('vICMSSTRet',10,2)->nullable();
$table->decimal('vBCFCPSTRet',10,2)->nullable();
$table->decimal('pFCPSTRet',10,2)->nullable();
$table->decimal('vFCPSTRet',10,2)->nullable();
$table->decimal('pRedBCEfet',10,2)->nullable();
$table->decimal('vBCEfet',10,2)->nullable();
$table->decimal('pICMSEfet',10,2)->nullable();
$table->decimal('vICMSEfet',10,2)->nullable();
$table->decimal('vICMSSubstituto',10,2)->nullable();
$table->string('modBCST',10)->nullable();
$table->decimal('pBCOp',10,2)->nullable();
$table->decimal('UFST',10,2)->nullable();
$table->decimal('vBCSTDest',10,2)->nullable();
$table->decimal('vICMSSTDest',10,2)->nullable();
$table->string('CSOSN',40)->nullable();
$table->decimal('pCredSN',10,2)->nullable();
$table->decimal('vCredICMSSN',10,2)->nullable();
$table->decimal('vBCUFDest',10,2)->nullable();
$table->decimal('vBCFCPUFDest',10,2)->nullable();
$table->decimal('pFCPUFDest',10,2)->nullable();
$table->decimal('pICMSUFDest',10,2)->nullable();
$table->decimal('pICMSInterPart',10,2)->nullable();
$table->decimal('vFCPUFDest',10,2)->nullable();
$table->decimal('vICMSUFDest',10,2)->nullable();
$table->decimal('vICMSUFRemet',10,2)->nullable();
$table->string('infAdProd',100)->nullable();
$table->decimal('valor_pauta', 10,2)->nullable()->default(0);
$table->decimal('qtde_pauta', 10,2)->nullable()->default(0);
$table->decimal('estadual',10,2)->nullable();
$table->decimal('municipal',10,2)->nullable();
$table->decimal('nacionalfederal',10,2)->nullable();
$table->decimal('importadosfederal',10,2)->nullable();
$table->decimal("vTotTrib",10,2)->nullable();
$table->string('destaca_icms',1)->default('S')->nullable();
$table->timestamps();
});
Configure os fillables do Model NfeItem
protected $fillable= [
'nfe_id',
'numero_item',
'produto_id',
'livre',
'cProd',
'cEAN',
'aliquota_pauta',
'qtde_pauta',
'xProd',
'NCM',
'importado',
'cBenef',
'NVE',
'EXTIPI',
'CFOP',
'uCom',
'qCom',
'vUnCom',
'vProd',
'cEANTrib',
'proporcao',
'uTrib',
'qTrib',
'vUnTrib',
'vFrete',
'vSeg',
'desconto_item',
'desconto_rateio',
'vDesc',
'vOutro',
'indTot',
'xPed',
'nItemPed',
'nFCI',
'cstIPI',
'clEnq',
'CNPJProd',
'cSelo',
'qSelo',
'cEnq',
'vIPI',
'vBCIPI',
'vICMSTRet',
'pIPI',
'qUnidIPI',
'vUnidIPI',
'tipo_calc_ipi',
'cstCOFINS',
'vBCCOFINSST',
'qBCProdConfisST',
'qBCProdPisST',
'vBCPISST',
'pCOFINS',
'tipo_calc_cofins',
'vAliqProd_cofins',
'vBCCOFINS',
'vCOFINS',
'vCOFINSST',
'tipo_calc_cofinsst',
'pCOFINSST',
'vAliqProd_cofinsst',
'cstPIS',
'tipo_calc_pis',
'vBCPIS',
'pPIS',
'vPIS',
'insere_ipi_na_base',
'vAliqProd_pis',
'tipo_calc_pisst',
'pPISST',
'vAliqProd_pisst',
'orig',
'cstICMS',
'modBC',
'vBCICMS',
'pICMS',
'vICMS',
'pFCP',
'vFCP',
'vBCFCP',
'pMVAST',
'pRedBCST',
'vBCST',
'pICMSST',
'vICMSST',
'vST',
'vBCFCPST',
'pFCPST',
'vFCPST',
'vICMSDeson',
'motDesICMS',
'pRedBC',
'vICMSOp',
'pDif',
'vICMSDif',
'vBCSTRet',
'pST',
'vICMSSTRet',
'vBCFCPSTRet',
'pFCPSTRet',
'vFCPSTRet',
'pRedBCEfet',
'vBCEfet',
'pICMSEfet',
'vICMSEfet',
'vICMSSubstituto',
'modBCST',
'pBCOp',
'UFST',
'vBCSTDest',
'vICMSSTDest',
'CSOSN',
'pCredSN',
'vCredICMSSN',
'vBCUFDest',
'vBCFCPUFDest',
'pFCPUFDest',
'pICMSUFDest',
'pICMSInter',
'pICMSInterPart',
'vFCPUFDest',
'vICMSUFDest',
'vICMSUFRemet',
'destaca_icms',
'estadual','municipal','nacionalfederal','importadosfederal',
];
faça o relacionamento da tabela NfeItem com as tabelas:
- Nfe
- Produto
public function nfe(){
return $this->belongsTo(Nfe::class, 'nfe_id');
}
public function produto(){
return $this->belongsTo(Produto::class, 'produto_id');
}
Crie o model NfeDuplicata
para criar o model NfeDuplicata use o comando: php artisan make:model NfeDuplicata -m
adicione os seguintes campos:
Schema::create('nfe_duplicatas', function (Blueprint $table) {
$table->id();
$table->bigInteger('nfe_id')->unsigned();
$table->foreign('nfe_id')->references('id')->on('nves');
$table->string('tPag',5)->nullable();
$table->string('indPag',1)->nullable();
$table->string('nDup',50);
$table->date('dVenc');
$table->decimal('vDup',10,2)->nullable();
$table->string('obs',80)->nullable();
$table->timestamps();
});
Crie o model NfeAutorizado
para criar o model NfeAutorizado use o comando: php artisan make:model NfeAutorizado -m
adicione os seguintes campos:
Schema::create('nfe_autorizados', function (Blueprint $table) {
$table->id();
$table->bigInteger('nfe_id')->unsigned();
$table->foreign('nfe_id')->references('id')->on('nves');
$table->string('aut_contato',50)->nullable();
$table->string('aut_cnpj',20);
$table->timestamps();
});
Crie o model NfeReferenciado
para criar o model NfeReferenciado use o comando: php artisan make:model NfeReferenciado -m
adicione os seguintes campos:
Schema::create('nfe_referenciados', function (Blueprint $table) {
$table->id();
$table->bigInteger('nfe_id')->unsigned();
$table->foreign('nfe_id')->references('id')->on('nves');
$table->string('tipo_nota_referenciada',10)->nullable();
$table->string('ref_NFe',50)->nullable();
$table->string('ref_ano_mes',10)->nullable();
$table->string('ref_num_nf',50)->nullable();
$table->string('ref_serie',10)->nullable();
$table->timestamps();
});
faça o relacionamento da tabela NfeReferenciado com as tabelas:
- Nfe
public function nfe(){
return $this->belongsTo(Nfe::class, 'nfe_id');
}
Crie o model NfeLog
para criar o model NfeLog use o comando: php artisan make:model NfeLog -m
adicione os seguintes campos:
Schema::create('nfe_logs', function (Blueprint $table) {
$table->id();
$table->bigInteger('nfe_id')->unsigned();
$table->foreign('nfe_id')->references('id')->on('nves');
$table->bigInteger('status_id')->nullable()->unsigned();
$table->foreign('status_id')->references('id')->on('statuses');
$table->date('data', 20);
$table->string('chave', 60)->nullable();
$table->string('titulo', 100);
$table->string('idLote', 100)->nullable();
$table->text('msg');
$table->timestamps();
});
faça o relacionamento da tabela NfeDuplicata com as tabelas:
- Nfe
- Status
public function nfe(){
return $this->belongsTo(Nfe::class, 'nfe_id');
}
public function status(){
return $this->belongsTo(Status::class, 'status_id');
}