Add properties necessary for factories to be called in isolation

This commit is contained in:
Marcus Moore 2023-03-16 17:08:18 -07:00
parent d9c1a548f1
commit 605f214597
No known key found for this signature in database
8 changed files with 15 additions and 0 deletions

View file

@ -35,11 +35,18 @@ class AccessoryFactory extends Factory
public function definition() public function definition()
{ {
return [ return [
'name' => sprintf(
'%s %s',
$this->faker->randomElement(['Bluetooth', 'Wired']),
$this->faker->randomElement(['Keyboard', 'Wired'])
),
'user_id' => function () { 'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin(); return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
}, },
'category_id' => Category::factory(),
'model_number' => $this->faker->numberBetween(1000000, 50000000), 'model_number' => $this->faker->numberBetween(1000000, 50000000),
'location_id' => Location::factory(), 'location_id' => Location::factory(),
'qty' => 1,
]; ];
} }

View file

@ -40,6 +40,7 @@ class AssetFactory extends Factory
{ {
return [ return [
'name' => null, 'name' => null,
'model_id' => AssetModel::factory(),
'rtd_location_id' => Location::factory(), 'rtd_location_id' => Location::factory(),
'serial' => $this->faker->uuid(), 'serial' => $this->faker->uuid(),
'status_id' => function () { 'status_id' => function () {

View file

@ -91,6 +91,7 @@ class AssetModelFactory extends Factory
return User::first() ?? User::factory()->firstAdmin(); return User::first() ?? User::factory()->firstAdmin();
}, },
'name' => $this->faker->catchPhrase(), 'name' => $this->faker->catchPhrase(),
'category_id' => Category::factory(),
'model_number' => $this->faker->creditCardNumber(), 'model_number' => $this->faker->creditCardNumber(),
'notes' => 'Created by demo seeder', 'notes' => 'Created by demo seeder',

View file

@ -33,6 +33,7 @@ class CategoryFactory extends Factory
{ {
return [ return [
'name' => $this->faker->catchPhrase(), 'name' => $this->faker->catchPhrase(),
'category_type' => 'asset',
'checkin_email' => $this->faker->boolean(), 'checkin_email' => $this->faker->boolean(),
'eula_text' => $this->faker->paragraph(), 'eula_text' => $this->faker->paragraph(),
'require_acceptance' => false, 'require_acceptance' => false,

View file

@ -34,6 +34,8 @@ class ConsumableFactory extends Factory
public function definition() public function definition()
{ {
return [ return [
'name' => $this->faker->word(),
'category_id' => Category::factory(),
'user_id' => function () { 'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin(); return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
}, },

View file

@ -32,6 +32,7 @@ class DepartmentFactory extends Factory
public function definition() public function definition()
{ {
return [ return [
'name' => $this->faker->word() . ' Department',
'user_id' => function () { 'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin(); return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
}, },

View file

@ -57,6 +57,7 @@ class LicenseFactory extends Factory
'reassignable' => $this->faker->boolean(), 'reassignable' => $this->faker->boolean(),
'termination_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d H:i:s'), 'termination_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d H:i:s'),
'supplier_id' => Supplier::factory(), 'supplier_id' => Supplier::factory(),
'category_id' => Category::factory(),
]; ];
} }

View file

@ -53,6 +53,7 @@ class ManufacturerFactory extends Factory
public function definition() public function definition()
{ {
return [ return [
'name' => $this->faker->company(),
'user_id' => function () { 'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin(); return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
}, },