simple DataFactory

This commit is contained in:
TimmensOne 2023-03-24 14:11:09 +01:00
parent d81439a4f7
commit 68735a3af7
3 changed files with 24 additions and 32 deletions

View File

@ -17,14 +17,14 @@ class DeviceFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
'device_id' => '1', 'device_id' => $this->faker->randomDigitNotNull(),
'title' => 'Test Device One', 'title' => $this->faker->word(),
'device_type' => 'type1', 'device_type' => $this->faker->domainWord(),
'description' => 'des', 'description' => $this->faker->sentence(),
'accessories' => 'acc', 'accessories' => $this->faker->word(),
'rz_username_buyer' => 'rzb', 'rz_username_buyer' => $this->faker->name(),
'serial_number' => '123', 'serial_number' => $this->faker->creditCardNumber(),
'image_url' => 'www.url.de' 'image_url' => $this->faker->url()
]; ];
} }
} }

View File

@ -19,21 +19,11 @@ class UserFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
'rz_username' => 'admin', 'rz_username' => 'rzu12345',
'full_name' => 'Admin', 'full_name' => $this->faker->name(),
'organisation_unit' => 11111111, 'organisation_unit' => $this->faker->company(),
'has_admin_privileges' => true, 'has_admin_privileges' => false,
'hashed_password' => 'vollgeheim', // password '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,
]);
}
} }

View File

@ -22,16 +22,18 @@ public function run(): void
// 'email' => 'test@example.com', // 'email' => 'test@example.com',
// ]); // ]);
Device::factory()->create([ Device::factory(2)->create();
'device_id' => '1',
'title' => 'Test Device One', //Device::factory()->create([
'device_type' => 'type1', // 'device_id' => '1',
'description' => 'des', // 'title' => 'Test Device One',
'accessories' => 'acc', // 'device_type' => 'type1',
'rz_username_buyer' => 'rzb', // 'description' => 'des',
'serial_number' => '123', // 'accessories' => 'acc',
'image_url' => 'www.url.de' // 'rz_username_buyer' => 'rzb',
]); // 'serial_number' => '123',
// 'image_url' => 'www.url.de'
//]);
//User::create([ //User::create([
// [ // [