mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 14:09:43 -08:00
Remove hard-coded manufacturer_id in factories
This commit is contained in:
parent
e8ff7cc09c
commit
7cf424b914
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\Manufacturer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
@ -46,7 +47,9 @@ class AccessoryFactory extends Factory
|
||||||
'name' => 'Bluetooth Keyboard',
|
'name' => 'Bluetooth Keyboard',
|
||||||
'image' => 'bluetooth.jpg',
|
'image' => 'bluetooth.jpg',
|
||||||
'category_id' => 8,
|
'category_id' => 8,
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'qty' => 10,
|
'qty' => 10,
|
||||||
'min_amt' => 2,
|
'min_amt' => 2,
|
||||||
'supplier_id' => rand(1, 5),
|
'supplier_id' => rand(1, 5),
|
||||||
|
@ -61,7 +64,9 @@ class AccessoryFactory extends Factory
|
||||||
'name' => 'USB Keyboard',
|
'name' => 'USB Keyboard',
|
||||||
'image' => 'usb-keyboard.jpg',
|
'image' => 'usb-keyboard.jpg',
|
||||||
'category_id' => 8,
|
'category_id' => 8,
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'qty' => 15,
|
'qty' => 15,
|
||||||
'min_amt' => 2,
|
'min_amt' => 2,
|
||||||
'supplier_id' => rand(1, 5),
|
'supplier_id' => rand(1, 5),
|
||||||
|
@ -76,7 +81,9 @@ class AccessoryFactory extends Factory
|
||||||
'name' => 'Magic Mouse',
|
'name' => 'Magic Mouse',
|
||||||
'image' => 'magic-mouse.jpg',
|
'image' => 'magic-mouse.jpg',
|
||||||
'category_id' => 9,
|
'category_id' => 9,
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'qty' => 13,
|
'qty' => 13,
|
||||||
'min_amt' => 2,
|
'min_amt' => 2,
|
||||||
'supplier_id' => rand(1, 5),
|
'supplier_id' => rand(1, 5),
|
||||||
|
@ -91,7 +98,9 @@ class AccessoryFactory extends Factory
|
||||||
'name' => 'Sculpt Comfort Mouse',
|
'name' => 'Sculpt Comfort Mouse',
|
||||||
'image' => 'comfort-mouse.jpg',
|
'image' => 'comfort-mouse.jpg',
|
||||||
'category_id' => 9,
|
'category_id' => 9,
|
||||||
'manufacturer_id' => 2,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
|
||||||
|
},
|
||||||
'qty' => 13,
|
'qty' => 13,
|
||||||
'min_amt' => 2,
|
'min_amt' => 2,
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\Manufacturer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
|
@ -116,7 +117,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'macbookair.jpg',
|
'image' => 'macbookair.jpg',
|
||||||
|
@ -133,7 +136,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 2,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
|
||||||
|
},
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'surface.jpg',
|
'image' => 'surface.jpg',
|
||||||
|
@ -150,7 +155,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 3,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
|
||||||
|
},
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'xps.jpg',
|
'image' => 'xps.jpg',
|
||||||
|
@ -167,7 +174,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 4,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('Asus', 'Asus')->first() ?? Manufacturer::factory()->asus();
|
||||||
|
},
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'zenbook.jpg',
|
'image' => 'zenbook.jpg',
|
||||||
|
@ -184,7 +193,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 5,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'HP')->first() ?? Manufacturer::factory()->hp();
|
||||||
|
},
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'spectre.jpg',
|
'image' => 'spectre.jpg',
|
||||||
|
@ -201,7 +212,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
return Category::find(1) ?? Category::factory()->assetLaptopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 6,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
|
||||||
|
},
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'yoga.png',
|
'image' => 'yoga.png',
|
||||||
|
@ -218,7 +231,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function (){
|
'category_id' => function (){
|
||||||
return Category::find(2) ?? Category::factory()->assetDesktopCategory();
|
return Category::find(2) ?? Category::factory()->assetDesktopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'eol' => '24',
|
'eol' => '24',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'imacpro.jpg',
|
'image' => 'imacpro.jpg',
|
||||||
|
@ -235,7 +250,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(2) ?? Category::factory()->assetDesktopCategory();
|
return Category::find(2) ?? Category::factory()->assetDesktopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 6,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
|
||||||
|
},
|
||||||
'eol' => '24',
|
'eol' => '24',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'lenovoi5.png',
|
'image' => 'lenovoi5.png',
|
||||||
|
@ -252,7 +269,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function (){
|
'category_id' => function (){
|
||||||
return Category::find(2) ?? Category::factory()->assetDesktopCategory();
|
return Category::find(2) ?? Category::factory()->assetDesktopCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 3,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
|
||||||
|
},
|
||||||
'model_number' => '5040 (MRR81)',
|
'model_number' => '5040 (MRR81)',
|
||||||
'eol' => '24',
|
'eol' => '24',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
|
@ -270,7 +289,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(6) ?? Category::factory()->assetVoipCategory();
|
return Category::find(6) ?? Category::factory()->assetVoipCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 8,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'soundstation.jpg',
|
'image' => 'soundstation.jpg',
|
||||||
|
@ -286,7 +307,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(6) ?? Category::factory()->assetVoipCategory();
|
return Category::find(6) ?? Category::factory()->assetVoipCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 8,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'cx3000.png',
|
'image' => 'cx3000.png',
|
||||||
|
@ -302,7 +325,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(3) ?? Category::factory()->assetTabletCategory();
|
return Category::find(3) ?? Category::factory()->assetTabletCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'ipad.jpg',
|
'image' => 'ipad.jpg',
|
||||||
|
@ -318,7 +343,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(3) ?? Category::factory()->assetTabletCategory();
|
return Category::find(3) ?? Category::factory()->assetTabletCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 6,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'tab3.png',
|
'image' => 'tab3.png',
|
||||||
|
@ -334,7 +361,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(4) ?? Category::factory()->assetMobileCategory();
|
return Category::find(4) ?? Category::factory()->assetMobileCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 3,
|
'depreciation_id' => 3,
|
||||||
'image' => 'iphone11.jpeg',
|
'image' => 'iphone11.jpeg',
|
||||||
|
@ -351,7 +380,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(4) ?? Category::factory()->assetMobileCategory();
|
return Category::find(4) ?? Category::factory()->assetMobileCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 1,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'iphone12.jpeg',
|
'image' => 'iphone12.jpeg',
|
||||||
|
@ -368,7 +399,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(5) ?? Category::factory()->assetDisplayCategory();
|
return Category::find(5) ?? Category::factory()->assetDisplayCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 7,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'LG')->first() ?? Manufacturer::factory()->lg();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 2,
|
'depreciation_id' => 2,
|
||||||
'image' => 'ultrafine.jpg',
|
'image' => 'ultrafine.jpg',
|
||||||
|
@ -384,7 +417,9 @@ class AssetModelFactory extends Factory
|
||||||
'category_id' => function () {
|
'category_id' => function () {
|
||||||
return Category::find(5) ?? Category::factory()->assetDisplayCategory();
|
return Category::find(5) ?? Category::factory()->assetDisplayCategory();
|
||||||
},
|
},
|
||||||
'manufacturer_id' => 3,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
|
||||||
|
},
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 2,
|
'depreciation_id' => 2,
|
||||||
'image' => 'ultrasharp.jpg',
|
'image' => 'ultrasharp.jpg',
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\Manufacturer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
@ -49,7 +50,9 @@ class ConsumableFactory extends Factory
|
||||||
return [
|
return [
|
||||||
'name' => 'Cardstock (White)',
|
'name' => 'Cardstock (White)',
|
||||||
'category_id' => 10,
|
'category_id' => 10,
|
||||||
'manufacturer_id' => 10,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Avery')->first() ?? Manufacturer::factory()->avery();
|
||||||
|
},
|
||||||
'qty' => 10,
|
'qty' => 10,
|
||||||
'min_amt' => 2,
|
'min_amt' => 2,
|
||||||
'company_id' => 3,
|
'company_id' => 3,
|
||||||
|
@ -63,7 +66,9 @@ class ConsumableFactory extends Factory
|
||||||
return [
|
return [
|
||||||
'name' => 'Laserjet Paper (Ream)',
|
'name' => 'Laserjet Paper (Ream)',
|
||||||
'category_id' => 10,
|
'category_id' => 10,
|
||||||
'manufacturer_id' => 10,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Avery')->first() ?? Manufacturer::factory()->avery();
|
||||||
|
},
|
||||||
'qty' => 20,
|
'qty' => 20,
|
||||||
'min_amt' => 2,
|
'min_amt' => 2,
|
||||||
];
|
];
|
||||||
|
@ -76,7 +81,9 @@ class ConsumableFactory extends Factory
|
||||||
return [
|
return [
|
||||||
'name' => 'Laserjet Toner (black)',
|
'name' => 'Laserjet Toner (black)',
|
||||||
'category_id' => 11,
|
'category_id' => 11,
|
||||||
'manufacturer_id' => 5,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'HP')->first() ?? Manufacturer::factory()->hp();
|
||||||
|
},
|
||||||
'qty' => 20,
|
'qty' => 20,
|
||||||
'min_amt' => 2,
|
'min_amt' => 2,
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
|
use App\Models\Manufacturer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
@ -64,7 +65,9 @@ class LicenseFactory extends Factory
|
||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Photoshop',
|
'name' => 'Photoshop',
|
||||||
'manufacturer_id' => 9,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
|
||||||
|
},
|
||||||
'purchase_cost' => '299.99',
|
'purchase_cost' => '299.99',
|
||||||
'seats' => 10,
|
'seats' => 10,
|
||||||
'purchase_order' => '13503Q',
|
'purchase_order' => '13503Q',
|
||||||
|
@ -81,7 +84,9 @@ class LicenseFactory extends Factory
|
||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Acrobat',
|
'name' => 'Acrobat',
|
||||||
'manufacturer_id' => 9,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
|
||||||
|
},
|
||||||
'purchase_cost' => '29.99',
|
'purchase_cost' => '29.99',
|
||||||
'seats' => 10,
|
'seats' => 10,
|
||||||
'category_id' => 14,
|
'category_id' => 14,
|
||||||
|
@ -96,7 +101,9 @@ class LicenseFactory extends Factory
|
||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'InDesign',
|
'name' => 'InDesign',
|
||||||
'manufacturer_id' => 9,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
|
||||||
|
},
|
||||||
'purchase_cost' => '199.99',
|
'purchase_cost' => '199.99',
|
||||||
'seats' => 10,
|
'seats' => 10,
|
||||||
'category_id' => 14,
|
'category_id' => 14,
|
||||||
|
@ -112,7 +119,9 @@ class LicenseFactory extends Factory
|
||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Office',
|
'name' => 'Office',
|
||||||
'manufacturer_id' => 2,
|
'manufacturer_id' => function () {
|
||||||
|
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
|
||||||
|
},
|
||||||
'purchase_cost' => '49.99',
|
'purchase_cost' => '49.99',
|
||||||
'seats' => 20,
|
'seats' => 20,
|
||||||
'category_id' => 15,
|
'category_id' => 15,
|
||||||
|
|
Loading…
Reference in a new issue