2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2021-06-10 13:18:00 -07:00
|
|
|
namespace Database\Seeders;
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
use App\Models\Asset;
|
2023-03-15 18:31:08 -07:00
|
|
|
use App\Models\Location;
|
2023-03-16 12:41:34 -07:00
|
|
|
use App\Models\Supplier;
|
2021-06-10 13:15:52 -07:00
|
|
|
use Illuminate\Database\Seeder;
|
2021-06-10 13:19:27 -07:00
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
2018-09-29 21:33:52 -07:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
class AssetSeeder extends Seeder
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
Asset::truncate();
|
2023-03-15 18:31:08 -07:00
|
|
|
|
|
|
|
if (! Location::count()) {
|
|
|
|
$this->call(LocationSeeder::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
$locationIds = Location::all()->pluck('id');
|
|
|
|
|
2023-03-16 12:41:34 -07:00
|
|
|
if (! Supplier::count()) {
|
|
|
|
$this->call(SupplierSeeder::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
$supplierIds = Supplier::all()->pluck('id');
|
|
|
|
|
|
|
|
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(),
|
|
|
|
]);
|
2023-03-15 18:31:08 -07:00
|
|
|
|
2023-03-16 12:41:34 -07:00
|
|
|
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(),
|
|
|
|
]);
|
2023-03-15 18:31:08 -07:00
|
|
|
|
2023-03-16 12:41:34 -07:00
|
|
|
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(),
|
|
|
|
]);
|
2023-03-15 18:31:08 -07:00
|
|
|
|
2023-03-16 12:41:34 -07:00
|
|
|
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(),
|
|
|
|
]);
|
2023-03-15 18:31:08 -07:00
|
|
|
|
2023-03-16 12:41:34 -07:00
|
|
|
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(),
|
|
|
|
]);
|
2023-03-15 18:31:08 -07:00
|
|
|
|
2023-03-16 12:41:34 -07:00
|
|
|
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(),
|
|
|
|
]);
|
2021-06-10 13:15:52 -07:00
|
|
|
|
|
|
|
$del_files = Storage::files('assets');
|
|
|
|
foreach ($del_files as $del_file) { // iterate files
|
2021-06-10 13:19:27 -07:00
|
|
|
Log::debug('Deleting: '.$del_files);
|
2021-06-10 13:15:52 -07:00
|
|
|
try {
|
|
|
|
Storage::disk('public')->delete('assets'.'/'.$del_files);
|
|
|
|
} catch (\Exception $e) {
|
2021-06-10 13:19:27 -07:00
|
|
|
Log::debug($e);
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DB::table('checkout_requests')->truncate();
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|