Skip to content

Commit 2cfa97c

Browse files
committed
develop/v0.1.0: Updated the database factory for the encryption model
1 parent 18dde9c commit 2cfa97c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

database/factories/EncryptedAttributesFactory.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Carbon\Carbon;
66
use Illuminate\Database\Eloquent\Factories\Factory;
7+
use Wazza\DbEncrypt\Helper\Encryptor;
78

89
class EncryptedAttributesFactory extends Factory
910
{
@@ -14,17 +15,17 @@ class EncryptedAttributesFactory extends Factory
1415
*/
1516
public function definition(): array
1617
{
18+
$randomText = $this->faker->text(50);
19+
$encryptedText = Encryptor::encrypt($randomText);
20+
$hashIndex = Encryptor::hash($randomText);
1721
return [
18-
'entity_id' => null,
19-
'state_id' => null,
20-
'type' => $this->faker->randomElement(['physical', 'billing', 'postal']),
21-
'building_name' => $this->faker->word(),
22-
'floor_number' => $this->faker->word(),
23-
'address1' => $this->faker->streetAddress(),
24-
'address2' => $this->faker->secondaryAddress(),
25-
'city' => $this->faker->city(),
26-
'postcode' => $this->faker->postcode(),
27-
'comments' => $this->faker->text(2000),
22+
'object_type' => 'users',
23+
'object_id' => $this->faker->randomNumber(5),
24+
'attribute' => $this->faker->randomElement(['social_security_number', 'private_note', 'custom_field']),
25+
'hash_index' => $hashIndex,
26+
'encrypted_value' => $encryptedText,
27+
'created_at' => now(),
28+
'updated_at' => now(),
2829
];
2930
}
3031
}

0 commit comments

Comments
 (0)