From 68735a3af7faceff5152fe6665573384f2257b88 Mon Sep 17 00:00:00 2001 From: TimmensOne Date: Fri, 24 Mar 2023 14:11:09 +0100 Subject: [PATCH] simple DataFactory --- .../database/factories/DeviceFactory.php | 16 +++++++------- device-app/database/factories/UserFactory.php | 18 ++++----------- .../database/seeders/DatabaseSeeder.php | 22 ++++++++++--------- 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/device-app/database/factories/DeviceFactory.php b/device-app/database/factories/DeviceFactory.php index 009920b..af568b2 100644 --- a/device-app/database/factories/DeviceFactory.php +++ b/device-app/database/factories/DeviceFactory.php @@ -17,14 +17,14 @@ class DeviceFactory extends Factory public function definition(): array { return [ - 'device_id' => '1', - 'title' => 'Test Device One', - 'device_type' => 'type1', - 'description' => 'des', - 'accessories' => 'acc', - 'rz_username_buyer' => 'rzb', - 'serial_number' => '123', - 'image_url' => 'www.url.de' + 'device_id' => $this->faker->randomDigitNotNull(), + 'title' => $this->faker->word(), + 'device_type' => $this->faker->domainWord(), + 'description' => $this->faker->sentence(), + 'accessories' => $this->faker->word(), + 'rz_username_buyer' => $this->faker->name(), + 'serial_number' => $this->faker->creditCardNumber(), + 'image_url' => $this->faker->url() ]; } } diff --git a/device-app/database/factories/UserFactory.php b/device-app/database/factories/UserFactory.php index a706390..04d94d0 100644 --- a/device-app/database/factories/UserFactory.php +++ b/device-app/database/factories/UserFactory.php @@ -19,21 +19,11 @@ class UserFactory extends Factory public function definition(): array { return [ - 'rz_username' => 'admin', - 'full_name' => 'Admin', - 'organisation_unit' => 11111111, - 'has_admin_privileges' => true, + 'rz_username' => 'rzu12345', + 'full_name' => $this->faker->name(), + 'organisation_unit' => $this->faker->company(), + 'has_admin_privileges' => false, 'hashed_password' => 'vollgeheim', // password ]; } - - /** - * Indicate that the model's email address should be unverified. - */ - public function unverified(): static - { - return $this->state(fn (array $attributes) => [ - 'email_verified_at' => null, - ]); - } } diff --git a/device-app/database/seeders/DatabaseSeeder.php b/device-app/database/seeders/DatabaseSeeder.php index 316e337..346f4c1 100644 --- a/device-app/database/seeders/DatabaseSeeder.php +++ b/device-app/database/seeders/DatabaseSeeder.php @@ -22,16 +22,18 @@ public function run(): void // 'email' => 'test@example.com', // ]); - Device::factory()->create([ - 'device_id' => '1', - 'title' => 'Test Device One', - 'device_type' => 'type1', - 'description' => 'des', - 'accessories' => 'acc', - 'rz_username_buyer' => 'rzb', - 'serial_number' => '123', - 'image_url' => 'www.url.de' - ]); + Device::factory(2)->create(); + + //Device::factory()->create([ + // 'device_id' => '1', + // 'title' => 'Test Device One', + // 'device_type' => 'type1', + // 'description' => 'des', + // 'accessories' => 'acc', + // 'rz_username_buyer' => 'rzb', + // 'serial_number' => '123', + // 'image_url' => 'www.url.de' + //]); //User::create([ // [