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\CustomField;
|
2017-11-22 15:57:05 -08:00
|
|
|
use App\Models\CustomFieldset;
|
2017-10-28 02:11:10 -07:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
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;
|
2021-06-10 13:15:52 -07:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
class CustomFieldSeeder extends Seeder
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
$columns = DB::getSchemaBuilder()->getColumnListing('assets');
|
|
|
|
|
|
|
|
foreach ($columns as $column) {
|
|
|
|
if (strpos($column, '_snipeit_') !== false) {
|
|
|
|
Schema::table('assets', function (Blueprint $table) use ($column) {
|
|
|
|
$table->dropColumn($column);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CustomField::truncate();
|
|
|
|
CustomFieldset::truncate();
|
|
|
|
DB::table('custom_field_custom_fieldset')->truncate();
|
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
CustomFieldset::factory()->count(1)->mobile()->create();
|
|
|
|
CustomFieldset::factory()->count(1)->computer()->create();
|
|
|
|
CustomField::factory()->count(1)->imei()->create();
|
|
|
|
CustomField::factory()->count(1)->phone()->create();
|
|
|
|
CustomField::factory()->count(1)->ram()->create();
|
|
|
|
CustomField::factory()->count(1)->cpu()->create();
|
|
|
|
CustomField::factory()->count(1)->macAddress()->create();
|
2023-10-25 21:04:30 -07:00
|
|
|
CustomField::factory()->count(1)->testEncrypted()->create();
|
|
|
|
CustomField::factory()->count(1)->testCheckbox()->create();
|
2023-12-13 06:03:13 -08:00
|
|
|
CustomField::factory()->count(1)->testRadio()->create();
|
2023-10-25 21:04:30 -07:00
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
|
|
|
|
DB::table('custom_field_custom_fieldset')->insert([
|
2018-09-29 22:17:36 -07:00
|
|
|
[
|
|
|
|
'custom_field_id' => '1',
|
2021-06-10 13:15:52 -07:00
|
|
|
'custom_fieldset_id' => '1',
|
2023-05-18 13:17:35 -07:00
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '2',
|
2021-06-10 13:15:52 -07:00
|
|
|
'custom_fieldset_id' => '1',
|
2023-05-18 13:17:35 -07:00
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
2023-05-22 17:40:06 -07:00
|
|
|
'custom_field_id' => '3',
|
|
|
|
'custom_fieldset_id' => '2',
|
2023-05-18 13:17:35 -07:00
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
2023-05-22 17:40:06 -07:00
|
|
|
'custom_field_id' => '4',
|
|
|
|
'custom_fieldset_id' => '2',
|
2023-05-18 13:17:35 -07:00
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
2023-05-22 17:40:06 -07:00
|
|
|
'custom_field_id' => '5',
|
|
|
|
'custom_fieldset_id' => '2',
|
2023-05-18 13:17:35 -07:00
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
|
2023-10-25 21:04:30 -07:00
|
|
|
[
|
|
|
|
'custom_field_id' => '6',
|
|
|
|
'custom_fieldset_id' => '2',
|
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
'custom_field_id' => '6',
|
|
|
|
'custom_fieldset_id' => '1',
|
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
'custom_field_id' => '7',
|
|
|
|
'custom_fieldset_id' => '2',
|
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '7',
|
|
|
|
'custom_fieldset_id' => '1',
|
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
|
|
|
],
|
|
|
|
|
2023-12-13 06:03:13 -08:00
|
|
|
[
|
|
|
|
'custom_field_id' => '8',
|
|
|
|
'custom_fieldset_id' => '2',
|
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '8',
|
|
|
|
'custom_fieldset_id' => '1',
|
|
|
|
'order' => 0,
|
|
|
|
'required' => 0,
|
|
|
|
],
|
|
|
|
|
2023-05-22 17:40:06 -07:00
|
|
|
]);
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|