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;
|
|
|
|
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();
|
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',
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '2',
|
2021-06-10 13:15:52 -07:00
|
|
|
'custom_fieldset_id' => '1',
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '3',
|
2021-06-10 13:15:52 -07:00
|
|
|
'custom_fieldset_id' => '2',
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '4',
|
2021-06-10 13:15:52 -07:00
|
|
|
'custom_fieldset_id' => '2',
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '5',
|
2021-06-10 13:15:52 -07:00
|
|
|
'custom_fieldset_id' => '2',
|
2018-09-29 22:17:36 -07:00
|
|
|
],
|
|
|
|
|
|
|
|
]);
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|