0
I have a field in the bank of up to 50 characters where I save the access key of a receipt, but when I search the information it brings me a totally different number, what happens?
Schema::create('nfe_table', function (Blueprint $table) {
$table->string('nfe_chave', 50);
$table->integer('nfe_numero');
$table->string('nfe_serie', 10);
$table->string('nfe_parc_cpf_cnpj_emit', 18);
$table->foreign('nfe_parc_cpf_cnpj_emit')->references('parc_cpf_cnpj')->on('parceiros_table');
$table->string('nfe_parc_cpf_cnpj_dest', 18);
$table->foreign('nfe_parc_cpf_cnpj_dest')->references('parc_cpf_cnpj')->on('parceiros_table');
$table->string('nfe_desc_nat_op', 200);
$table->dateTime('nfe_dt_emiss');
$table->dateTime('nfe_dt_receb');
$table->dateTime('nfe_dt_venc')->nullable();
$table->double('nfe_vl');
$table->string('nfe_parc_cpf_cnpj_transp', 18)->default("");
$table->foreign('nfe_parc_cpf_cnpj_transp')->references('parc_cpf_cnpj')->on('parceiros_table');
$table->string('nfe_tp_frete', 3)->default(0);
$table->string('nfe_transp_placa', 9)->default("");
$table->string('nfe_transp_placa_uf', 3)->default("");
$table->integer('nfe_vol')->default(0);
$table->string('nfe_vol_especie')->default("VOL");
$table->double('nfe_peso_bruto')->default(0);
$table->double('nfe_peso_liq')->default(0);
$table->boolean('nfe_is_recebida')->default(0);
$table->integer('nfe_user_id')->unsigned();
$table->foreign('nfe_user_id')->references('id')->on('users');
$table->string('nfe_inf_adic', 1000)->default("");
$table->primary(['nfe_chave']);
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
});
}
Model NFE
use Notifiable;
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = 'nfe_table';
protected $primaryKey = 'nfe_chave';
protected $fillable = [
'nfe_chave', 'nfe_numero', 'nfe_serie',
'nfe_parc_cpf_cnpj_emit', 'nfe_parc_cpf_cnpj_dest', 'nfe_desc_nat_op', 'nfe_dt_emiss', 'nfe_dt_receb', 'nfe_dt_venc', 'nfe_vl',
'nfe_parc_cpf_cnpj_transp', 'nfe_tp_frete', 'nfe_transp_placa', 'nfe_transp_placa_uf', 'nfe_vol', 'nfe_vol_especie',
'nfe_peso_bruto', 'nfe_peso_liq', 'nfe_is_recebida', 'nfe_user_id', 'nfe_inf_adic', 'nfe_confirm_receb',
];
accessing the note object variable in the dd method:
But accessing it directly with for example:
dd($nfe->nfe_chave);
Bring me this, I don’t understand and I needed to show the key on a receipt form
9223372036854775807
Does your model have a function with the same name as this attribute? I wonder why exactly this happened to me, when I tried to take a value from an attribute, returned me a value other than saved, but it was because I had a relationship function in my model, with this it executed the function q returns another value and not the real value of the attribute.
– Kayo Bruno
It is a new feature not yet created methods to bring within the model! and continues to bring me a value that is not saved, very strange! funny that it is the only field bringing me incorrect value and method dd(); it brings me the correct value but at the time of using and brings me a different value!
– Ulisses Gimenes
Do the same test with another invoice.
– Kayo Bruno
All with the same problem and I need the access key so I can use it to check the notes! only that I do not understand is that for all the notes he shows me the same value ( 9223372036854775807 ), from where he picks up this number?
– Ulisses Gimenes
Worst of all, I’ve done a lot of research and I can’t find anything!
– Ulisses Gimenes
Put your whole function where it happens. Remove this code from Migration leaves only the code where the problem happens.
– Kayo Bruno
I created an outline solution but if someone can give me a light, the access key is my primary key, I created a field as key copy, and as it is not the primary brought me the correct value! I don’t know why it happens!
– Ulisses Gimenes
Since I can’t comment yet, please send the Model NFE code and the listing code please.
– Lucas Antonio
I’ll try to ask the question!
– Ulisses Gimenes