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
{
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()
];
}
}

View File

@ -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,
]);
}
}

View File

@ -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([
// [