1
Save, I need help. I am developing a system that has a user table and a table of enrollments. The registration data is related to the CPF registered in the Users table. The problem is that now I need to encrypt the data of the tables, I created user and registration Seeds, the user is created with the encryption normally, but the registration presents error that I believe is why I can not make the relationship with the table users.
Seed of users:
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Crypt;
use App\Models\Usuarios;
class UsuarioSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Usuarios::create([
'nome' => Crypt::encryptString('Teste 2'),
'cpf' => Crypt::encryptString('000000'),
'email' => Crypt::encryptString('[email protected]'),
'telefone' => '000000',
'endereco' => 'nao tem',
'numero' => '50',
'complemento' => 'nao',
'bairro' => 'nao tem',
'cidade' => 'nao tem',
'estado' => 'nao tem',
'cep' => '00000000',
'celular' => '000000000000',
'password' => '$2y$10$kOAYngEkkn30WFwtePAX1ODrNNXtuCA0AKt9yhJSnZYFcqIVoj5LK',
'email_verified_at' => NULL,
'remember_token' => 'fpgOcf1SR5BLtb2GNEVigbCD2Zp7qrWMIDmwq7Qylp0vLRB4Oo7CiUG6LH46'
]);
Usuarios::create([
'nome' => Crypt::encryptString('Teste 3'),
'cpf' => Crypt::encryptString('00000000'),
'email' => Crypt::encryptString('[email protected]'),
'telefone' => '000000000',
'endereco' => 'nao tem',
'numero' => '90',
'complemento' => NULL,
'bairro' => 'nao tem',
'cidade' => 'nao tem',
'estado' => 'AC',
'cep' => '0000000000',
'celular' => NULL,
'password' => '$2y$10$kOAYngEkkn30WFwtePAX1ODrNNXtuCA0AKt9yhJSnZYFcqIVoj5LK',
'email_verified_at' => NULL,
'remember_token' => NULL
]);
}
}
Seed of registrations:
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Crypt;
use App\Models\Matriculas;
class MatriculasSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Matriculas::create([
'matricula' => 100005,
'nivel_acesso' => 1,
'jornada' => 40,
'bloqueado' => 0,
'aprovado' => 1,
'cpf' => Crypt::encryptString('000000'),
'data_admissao' => '1999-11-09',
'cargo' => 'Administrador'
]);
Matriculas::create([
'matricula' => 100006,
'nivel_acesso' => 1,
'jornada' => 44,
'bloqueado' => 0,
'aprovado' => 1,
'cpf' => Crypt::encryptString('000000'),
'data_admissao' => '2003-06-06',
'cargo' => 'Administrador'
]);
Matriculas::create([
'matricula' => 100007,
'nivel_acesso' => 1,
'jornada' => 35,
'bloqueado' => 0,
'aprovado' => 1,
'cpf' => Crypt::encryptString('00000000'),
'data_admissao' => '2002-11-11',
'cargo' => 'Administrador'
]);
}
}
A Disclaimer is that the registrations are in a separate table because a CPF may have more than one registration
I don’t understand why you’re doing this???
– novic
Do you say cryptography? If yes are orders
– Pedro Bonel
You have to take the same relationship data to include in the other table! That’s what you have to do!
– novic
What needs to be done I know, the problem is how, if every time I call this encryption function the data comes out differently, even being texts equal
– Pedro Bonel
If you don’t know very well why only create a variable in the scope of the function and use in the two recordings! , understand? if you make a run() and put sequence what you need! simple so solves and is ideal this way
– novic
Now I get it, really worth it
– Pedro Bonel