mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
Remove hard-coded supplier_id in factories
This commit is contained in:
parent
0ec885bf18
commit
7062b0acaa
|
@ -5,6 +5,7 @@ namespace Database\Factories;
|
|||
use App\Models\Category;
|
||||
use App\Models\Location;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
|
@ -56,7 +57,7 @@ class AccessoryFactory extends Factory
|
|||
},
|
||||
'qty' => 10,
|
||||
'min_amt' => 2,
|
||||
'supplier_id' => rand(1, 5),
|
||||
'supplier_id' => Supplier::factory(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
@ -75,7 +76,7 @@ class AccessoryFactory extends Factory
|
|||
},
|
||||
'qty' => 15,
|
||||
'min_amt' => 2,
|
||||
'supplier_id' => rand(1, 5),
|
||||
'supplier_id' => Supplier::factory(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
@ -94,7 +95,7 @@ class AccessoryFactory extends Factory
|
|||
},
|
||||
'qty' => 13,
|
||||
'min_amt' => 2,
|
||||
'supplier_id' => rand(1, 5),
|
||||
'supplier_id' => Supplier::factory(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ namespace Database\Factories;
|
|||
|
||||
use App\Models\Category;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
|
@ -55,7 +56,7 @@ class LicenseFactory extends Factory
|
|||
'expiration_date' => $this->faker->dateTimeBetween('now', '+3 years', date_default_timezone_get())->format('Y-m-d H:i:s'),
|
||||
'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' => $this->faker->numberBetween(1, 5),
|
||||
'supplier_id' => Supplier::factory(),
|
||||
'category_id' => Category::where('category_type', '=', 'license')->inRandomOrder()->first()->id
|
||||
];
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Location;
|
||||
use App\Models\Supplier;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@ -22,10 +23,28 @@ class AccessorySeeder extends Seeder
|
|||
|
||||
$locationIds = Location::all()->pluck('id');
|
||||
|
||||
Accessory::factory()->count(1)->appleUsbKeyboard()->create(['location_id' => $locationIds->random()]);
|
||||
Accessory::factory()->count(1)->appleBtKeyboard()->create(['location_id' => $locationIds->random()]);
|
||||
Accessory::factory()->count(1)->appleMouse()->create(['location_id' => $locationIds->random()]);
|
||||
Accessory::factory()->count(1)->microsoftMouse()->create(['location_id' => $locationIds->random()]);
|
||||
if (! Supplier::count()) {
|
||||
$this->call(SupplierSeeder::class);
|
||||
}
|
||||
|
||||
$supplierIds = Supplier::all()->pluck('id');
|
||||
|
||||
Accessory::factory()->count(1)->appleUsbKeyboard()->create([
|
||||
'location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Accessory::factory()->count(1)->appleBtKeyboard()->create([
|
||||
'location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Accessory::factory()->count(1)->appleMouse()->create([
|
||||
'location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Accessory::factory()->count(1)->microsoftMouse()->create([
|
||||
'location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
|
||||
$src = public_path('/img/demo/accessories/');
|
||||
$dst = 'accessories'.'/';
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||
|
||||
use App\Models\Asset;
|
||||
use App\Models\Location;
|
||||
use App\Models\Supplier;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@ -21,31 +22,97 @@ class AssetSeeder extends Seeder
|
|||
|
||||
$locationIds = Location::all()->pluck('id');
|
||||
|
||||
Asset::factory()->count(1000)->laptopMbp()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(50)->laptopMbpPending()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(50)->laptopMbpArchived()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(50)->laptopAir()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(5)->laptopSurface()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(5)->laptopXps()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(5)->laptopSpectre()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(5)->laptopZenbook()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(3)->laptopYoga()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
if (! Supplier::count()) {
|
||||
$this->call(SupplierSeeder::class);
|
||||
}
|
||||
|
||||
Asset::factory()->count(30)->desktopMacpro()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(30)->desktopLenovoI5()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(30)->desktopOptiplex()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
$supplierIds = Supplier::all()->pluck('id');
|
||||
|
||||
Asset::factory()->count(5)->confPolycom()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(2)->confPolycomcx()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(1000)->laptopMbp()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(50)->laptopMbpPending()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(50)->laptopMbpArchived()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(50)->laptopAir()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(5)->laptopSurface()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(5)->laptopXps()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(5)->laptopSpectre()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(5)->laptopZenbook()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(3)->laptopYoga()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
|
||||
Asset::factory()->count(12)->tabletIpad()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(4)->tabletTab3()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(30)->desktopMacpro()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(30)->desktopLenovoI5()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(30)->desktopOptiplex()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
|
||||
Asset::factory()->count(27)->phoneIphone11()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(40)->phoneIphone12()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(5)->confPolycom()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(2)->confPolycomcx()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
|
||||
Asset::factory()->count(10)->ultrafine()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(10)->ultrasharp()->create(['rtd_location_id' => $locationIds->random()]);
|
||||
Asset::factory()->count(12)->tabletIpad()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(4)->tabletTab3()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
|
||||
Asset::factory()->count(27)->phoneIphone11()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(40)->phoneIphone12()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
|
||||
Asset::factory()->count(10)->ultrafine()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
Asset::factory()->count(10)->ultrasharp()->create([
|
||||
'rtd_location_id' => $locationIds->random(),
|
||||
'supplier_id' => $supplierIds->random(),
|
||||
]);
|
||||
|
||||
$del_files = Storage::files('assets');
|
||||
foreach ($del_files as $del_file) { // iterate files
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Supplier;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LicenseSeeder extends Seeder
|
||||
|
@ -12,9 +13,16 @@ class LicenseSeeder extends Seeder
|
|||
{
|
||||
License::truncate();
|
||||
LicenseSeat::truncate();
|
||||
License::factory()->count(1)->photoshop()->create();
|
||||
License::factory()->count(1)->acrobat()->create();
|
||||
License::factory()->count(1)->indesign()->create();
|
||||
License::factory()->count(1)->office()->create();
|
||||
|
||||
if (! Supplier::count()) {
|
||||
$this->call(SupplierSeeder::class);
|
||||
}
|
||||
|
||||
$supplierIds = Supplier::all()->pluck('id');
|
||||
|
||||
License::factory()->count(1)->photoshop()->create(['supplier_id' => $supplierIds->random()]);
|
||||
License::factory()->count(1)->acrobat()->create(['supplier_id' => $supplierIds->random()]);
|
||||
License::factory()->count(1)->indesign()->create(['supplier_id' => $supplierIds->random()]);
|
||||
License::factory()->count(1)->office()->create(['supplier_id' => $supplierIds->random()]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue