34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\DeviceModel;
|
|
use App\Models\DeviceType;
|
|
use App\Models\DeviceVendor;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class DeviceCatalogSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
foreach (['MikroTik', 'ZTE', 'C-Data', 'HSGQ', 'HiOSO', 'Hisfocus'] as $name) {
|
|
DeviceVendor::updateOrCreate(['slug' => str($name)->slug()], ['name' => $name, 'is_active' => true]);
|
|
}
|
|
foreach (['Router', 'OLT', 'Switch', 'Access Point', 'Server', 'Other'] as $name) {
|
|
DeviceType::updateOrCreate(['slug' => str($name)->slug()], ['name' => $name, 'is_active' => true]);
|
|
}
|
|
|
|
$zte = DeviceVendor::where('slug', 'zte')->firstOrFail();
|
|
$olt = DeviceType::where('slug', 'olt')->firstOrFail();
|
|
foreach (['C300', 'C320'] as $name) {
|
|
DeviceModel::updateOrCreate(
|
|
['device_vendor_id' => $zte->id, 'name' => $name],
|
|
['device_type_id' => $olt->id, 'model_code' => $name, 'is_active' => true],
|
|
);
|
|
}
|
|
}
|
|
}
|