Skip to content

A free open source IT asset/license management system

Add properties necessary for factories to be called in isolation

Marcus Moore605f2145978f
diff --git a/database/factories/AccessoryFactory.php b/database/factories/AccessoryFactory.php
index e9c90acd9c..5d17fe11c6 100644
--- a/database/factories/AccessoryFactory.php
+++ b/database/factories/AccessoryFactory.php
@@ -35,11 +35,18 @@ class AccessoryFactory extends Factory
public function definition()
{
return [
+ 'name' => sprintf(
+ '%s %s',
+ $this->faker->randomElement(['Bluetooth', 'Wired']),
+ $this->faker->randomElement(['Keyboard', 'Wired'])
+ ),
'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
},
+ 'category_id' => Category::factory(),
'model_number' => $this->faker->numberBetween(1000000, 50000000),
'location_id' => Location::factory(),
+ 'qty' => 1,
];
}
diff --git a/database/factories/AssetFactory.php b/database/factories/AssetFactory.php
index c269d77e36..e86cf02562 100644
--- a/database/factories/AssetFactory.php
+++ b/database/factories/AssetFactory.php
@@ -40,6 +40,7 @@ class AssetFactory extends Factory
{
return [
'name' => null,
+ 'model_id' => AssetModel::factory(),
'rtd_location_id' => Location::factory(),
'serial' => $this->faker->uuid(),
'status_id' => function () {
diff --git a/database/factories/AssetModelFactory.php b/database/factories/AssetModelFactory.php
index 6a7da364fc..02917fb17a 100644
--- a/database/factories/AssetModelFactory.php
+++ b/database/factories/AssetModelFactory.php
@@ -91,6 +91,7 @@ class AssetModelFactory extends Factory
return User::first() ?? User::factory()->firstAdmin();
},
'name' => $this->faker->catchPhrase(),
+ 'category_id' => Category::factory(),
'model_number' => $this->faker->creditCardNumber(),
'notes' => 'Created by demo seeder',
diff --git a/database/factories/CategoryFactory.php b/database/factories/CategoryFactory.php
index 9e251931d1..8802dbb5f6 100644
--- a/database/factories/CategoryFactory.php
+++ b/database/factories/CategoryFactory.php
@@ -33,6 +33,7 @@ class CategoryFactory extends Factory
{
return [
'name' => $this->faker->catchPhrase(),
+ 'category_type' => 'asset',
'checkin_email' => $this->faker->boolean(),
'eula_text' => $this->faker->paragraph(),
'require_acceptance' => false,
diff --git a/database/factories/ConsumableFactory.php b/database/factories/ConsumableFactory.php
index c52ed35367..534fcd6a87 100644
--- a/database/factories/ConsumableFactory.php
+++ b/database/factories/ConsumableFactory.php
@@ -34,6 +34,8 @@ class ConsumableFactory extends Factory
public function definition()
{
return [
+ 'name' => $this->faker->word(),
+ 'category_id' => Category::factory(),
'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
},
diff --git a/database/factories/DepartmentFactory.php b/database/factories/DepartmentFactory.php
index 8d10c606cc..e7a41ff0dd 100644
--- a/database/factories/DepartmentFactory.php
+++ b/database/factories/DepartmentFactory.php
@@ -32,6 +32,7 @@ class DepartmentFactory extends Factory
public function definition()
{
return [
+ 'name' => $this->faker->word() . ' Department',
'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
},
diff --git a/database/factories/LicenseFactory.php b/database/factories/LicenseFactory.php
index b518de2c64..364b6fb470 100644
--- a/database/factories/LicenseFactory.php
+++ b/database/factories/LicenseFactory.php
@@ -57,6 +57,7 @@ class LicenseFactory extends Factory
'reassignable' => $this->faker->boolean(),
'termination_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d H:i:s'),
'supplier_id' => Supplier::factory(),
+ 'category_id' => Category::factory(),
];
}
diff --git a/database/factories/ManufacturerFactory.php b/database/factories/ManufacturerFactory.php
index 3b913dd7a6..08be16672a 100644
--- a/database/factories/ManufacturerFactory.php
+++ b/database/factories/ManufacturerFactory.php
@@ -53,6 +53,7 @@ class ManufacturerFactory extends Factory
public function definition()
{
return [
+ 'name' => $this->faker->company(),
'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
},