Remove hard-coded depreciation_id in factories

This commit is contained in:
Marcus Moore 2023-03-14 17:51:20 -07:00
parent f7577bff52
commit fb789eb048
No known key found for this signature in database

View file

@ -2,6 +2,7 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\Depreciation;
use App\Models\Manufacturer; use App\Models\Manufacturer;
use App\Models\User; use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
@ -102,7 +103,9 @@ class AssetModelFactory extends Factory
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory(); return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
}, },
'eol' => '36', 'eol' => '36',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'mbp.jpg', 'image' => 'mbp.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -121,7 +124,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple(); return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
}, },
'eol' => '36', 'eol' => '36',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'macbookair.jpg', 'image' => 'macbookair.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -140,7 +145,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft(); return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
}, },
'eol' => '36', 'eol' => '36',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'surface.jpg', 'image' => 'surface.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -159,7 +166,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell(); return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
}, },
'eol' => '36', 'eol' => '36',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'xps.jpg', 'image' => 'xps.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -178,7 +187,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Asus')->first() ?? Manufacturer::factory()->asus(); return Manufacturer::where('name', 'Asus')->first() ?? Manufacturer::factory()->asus();
}, },
'eol' => '36', 'eol' => '36',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'zenbook.jpg', 'image' => 'zenbook.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -197,7 +208,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'HP')->first() ?? Manufacturer::factory()->hp(); return Manufacturer::where('name', 'HP')->first() ?? Manufacturer::factory()->hp();
}, },
'eol' => '36', 'eol' => '36',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'spectre.jpg', 'image' => 'spectre.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -216,7 +229,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo(); return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
}, },
'eol' => '36', 'eol' => '36',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'yoga.png', 'image' => 'yoga.png',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -235,7 +250,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple(); return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
}, },
'eol' => '24', 'eol' => '24',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'imacpro.jpg', 'image' => 'imacpro.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -254,7 +271,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo(); return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
}, },
'eol' => '24', 'eol' => '24',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'lenovoi5.png', 'image' => 'lenovoi5.png',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -274,7 +293,9 @@ class AssetModelFactory extends Factory
}, },
'model_number' => '5040 (MRR81)', 'model_number' => '5040 (MRR81)',
'eol' => '24', 'eol' => '24',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'optiplex.jpg', 'image' => 'optiplex.jpg',
'fieldset_id' => 2, 'fieldset_id' => 2,
]; ];
@ -293,7 +314,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom(); return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'soundstation.jpg', 'image' => 'soundstation.jpg',
]; ];
}); });
@ -311,7 +334,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom(); return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'cx3000.png', 'image' => 'cx3000.png',
]; ];
}); });
@ -329,7 +354,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple(); return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'ipad.jpg', 'image' => 'ipad.jpg',
]; ];
}); });
@ -347,7 +374,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo(); return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'tab3.png', 'image' => 'tab3.png',
]; ];
}); });
@ -365,7 +394,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple(); return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 3, 'depreciation_id' => function () {
return Depreciation::where('name', 'Mobile Phone Depreciation')->first() ?? Depreciation::factory()->mobilePhones();
},
'image' => 'iphone11.jpeg', 'image' => 'iphone11.jpeg',
'fieldset_id' => 1, 'fieldset_id' => 1,
]; ];
@ -384,7 +415,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple(); return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 1, 'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'iphone12.jpeg', 'image' => 'iphone12.jpeg',
'fieldset_id' => 1, 'fieldset_id' => 1,
]; ];
@ -403,7 +436,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'LG')->first() ?? Manufacturer::factory()->lg(); return Manufacturer::where('name', 'LG')->first() ?? Manufacturer::factory()->lg();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 2, 'depreciation_id' => function () {
return Depreciation::where('name', 'Display Depreciation')->first() ?? Depreciation::factory()->display();
},
'image' => 'ultrafine.jpg', 'image' => 'ultrafine.jpg',
]; ];
}); });
@ -421,7 +456,9 @@ class AssetModelFactory extends Factory
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell(); return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
}, },
'eol' => '12', 'eol' => '12',
'depreciation_id' => 2, 'depreciation_id' => function () {
return Depreciation::where('name', 'Display Depreciation')->first() ?? Depreciation::factory()->display();
},
'image' => 'ultrasharp.jpg', 'image' => 'ultrasharp.jpg',
]; ];
}); });