Remove hard-coded model_id in asset factory

This commit is contained in:
Marcus Moore 2023-03-14 13:56:25 -07:00
parent ef8007a890
commit 1ff094dd47
No known key found for this signature in database

View file

@ -66,7 +66,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
},
];
});
}
@ -75,7 +77,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
},
'status_id' => function () {
return Statuslabel::where('name', 'Pending')->first() ?? Statuslabel::factory()->pending()->make(['name' => 'Pending']);
},
@ -87,7 +91,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
},
'status_id' => function () {
return Statuslabel::where('name', 'Archived')->first() ?? Statuslabel::factory()->archived()->make(['name' => 'Archived']);
},
@ -99,7 +105,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 2,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Air')->first() ?? AssetModel::factory()->mbpAirModel();
},
];
});
}
@ -108,7 +116,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 3,
'model_id' => function () {
return AssetModel::where('name', 'Surface')->first() ?? AssetModel::factory()->surfaceModel();
},
];
});
}
@ -117,7 +127,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 4,
'model_id' => function () {
return AssetModel::where('name', 'XPS 13')->first() ?? AssetModel::factory()->xps13Model();
},
];
});
}
@ -126,7 +138,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 5,
'model_id' => function () {
return AssetModel::where('name', 'Spectre')->first() ?? AssetModel::factory()->spectreModel();
},
];
});
}
@ -135,7 +149,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 6,
'model_id' => function () {
return AssetModel::where('name', 'ZenBook UX310')->first() ?? AssetModel::factory()->zenbookModel();
},
];
});
}
@ -144,7 +160,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 7,
'model_id' => function () {
return AssetModel::where('name', 'Yoga 910')->first() ?? AssetModel::factory()->yogaModel();
},
];
});
}
@ -153,7 +171,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 8,
'model_id' => function () {
return AssetModel::where('name', 'iMac Pro')->first() ?? AssetModel::factory()->macproModel();
},
];
});
}
@ -162,7 +182,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 9,
'model_id' => function () {
return AssetModel::where('name', 'Lenovo Intel Core i5')->first() ?? AssetModel::factory()->lenovoI5Model();
},
];
});
}
@ -171,7 +193,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 10,
'model_id' => function () {
return AssetModel::where('name', 'OptiPlex')->first() ?? AssetModel::factory()->optiplexModel();
},
];
});
}
@ -180,7 +204,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 11,
'model_id' => function () {
return AssetModel::where('name', 'SoundStation 2')->first() ?? AssetModel::factory()->polycomModel();
},
];
});
}
@ -189,7 +215,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 12,
'model_id' => function () {
return AssetModel::where('name', 'Polycom CX3000 IP Conference Phone')->first() ?? AssetModel::factory()->polycomcxModel();
},
];
});
}
@ -198,7 +226,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 13,
'model_id' => function () {
return AssetModel::where('name', 'iPad Pro')->first() ?? AssetModel::factory()->ipadModel();
},
];
});
}
@ -207,7 +237,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 14,
'model_id' => function () {
return AssetModel::where('name', 'Tab3')->first() ?? AssetModel::factory()->tab3Model();
},
];
});
}
@ -216,7 +248,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 15,
'model_id' => function () {
return AssetModel::where('name', 'iPhone 11')->first() ?? AssetModel::factory()->iphone11Model();
},
];
});
}
@ -225,7 +259,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 16,
'model_id' => function () {
return AssetModel::where('name', 'iPhone 12')->first() ?? AssetModel::factory()->iphone12Model();
},
];
});
}
@ -234,7 +270,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 17,
'model_id' => function () {
return AssetModel::where('name', 'Ultrafine 4k')->first() ?? AssetModel::factory()->ultrafine();
},
];
});
}
@ -243,7 +281,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 18,
'model_id' => function () {
return AssetModel::where('name', 'Ultrasharp U2415')->first() ?? AssetModel::factory()->ultrasharp();
},
];
});
}
@ -252,7 +292,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
},
'assigned_to' => \App\Models\User::factory()->create()->id,
'assigned_type' => \App\Models\User::class,
];
@ -263,7 +305,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
},
'assigned_to' => \App\Models\Location::factory()->create()->id,
'assigned_type' => \App\Models\Location::class,
];
@ -274,7 +318,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
},
'assigned_to' => \App\Models\Asset::factory()->create()->id,
'assigned_type' => \App\Models\Asset::class,
];
@ -285,7 +331,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
},
];
});
}
@ -294,7 +342,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
},
'deleted_at' => $this->faker->dateTime(),
];
});