2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
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\Support\Facades\Schema;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
class CustomFieldSeeder extends Seeder
|
|
|
|
{
|
|
|
|
public function run()
|
|
|
|
{
|
2017-10-28 02:11:10 -07:00
|
|
|
$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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
CustomField::truncate();
|
2017-11-22 15:57:05 -08:00
|
|
|
CustomFieldset::truncate();
|
|
|
|
DB::table('custom_field_custom_fieldset')->truncate();
|
2018-09-29 22:17:36 -07:00
|
|
|
|
|
|
|
factory(CustomFieldset::class, 1)->states('mobile')->create();
|
|
|
|
factory(CustomFieldset::class, 1)->states('computer')->create();
|
|
|
|
factory(CustomField::class, 1)->states('imei')->create();
|
|
|
|
factory(CustomField::class, 1)->states('phone')->create();
|
|
|
|
factory(CustomField::class, 1)->states('ram')->create();
|
|
|
|
factory(CustomField::class, 1)->states('cpu')->create();
|
|
|
|
|
|
|
|
DB::table('custom_field_custom_fieldset')->insert([
|
|
|
|
[
|
|
|
|
'custom_field_id' => '1',
|
|
|
|
'custom_fieldset_id' => '1'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '2',
|
|
|
|
'custom_fieldset_id' => '1'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '3',
|
|
|
|
'custom_fieldset_id' => '2'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '4',
|
|
|
|
'custom_fieldset_id' => '2'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'custom_field_id' => '5',
|
|
|
|
'custom_fieldset_id' => '2'
|
|
|
|
],
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|