mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Added more seeders for better custom field displays on seeding
This commit is contained in:
parent
a481fa2921
commit
4975f9100c
|
@ -33,6 +33,7 @@ $factory->state(App\Models\AssetModel::class, 'mbp-13-model', function ($faker)
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'mbp.jpg',
|
'image' => 'mbp.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ $factory->state(App\Models\AssetModel::class, 'mbp-air-model', function ($faker)
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'macbookair.jpg',
|
'image' => 'macbookair.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,6 +59,7 @@ $factory->state(App\Models\AssetModel::class, 'surface-model', function ($faker)
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'surface.jpg',
|
'image' => 'surface.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -69,6 +72,7 @@ $factory->state(App\Models\AssetModel::class, 'xps13-model', function ($faker) {
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'xps.jpg',
|
'image' => 'xps.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,6 +85,7 @@ $factory->state(App\Models\AssetModel::class, 'zenbook-model', function ($faker)
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'zenbook.jpg',
|
'image' => 'zenbook.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -93,6 +98,7 @@ $factory->state(App\Models\AssetModel::class, 'spectre-model', function ($faker)
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'spectre.jpg',
|
'image' => 'spectre.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -105,6 +111,7 @@ $factory->state(App\Models\AssetModel::class, 'yoga-model', function ($faker) {
|
||||||
'eol' => '36',
|
'eol' => '36',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'yoga.png',
|
'image' => 'yoga.png',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -123,6 +130,7 @@ $factory->state(App\Models\AssetModel::class, 'macpro-model', function ($faker)
|
||||||
'eol' => '24',
|
'eol' => '24',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'imacpro.jpg',
|
'image' => 'imacpro.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -134,6 +142,7 @@ $factory->state(App\Models\AssetModel::class, 'lenovo-i5-model', function ($fake
|
||||||
'eol' => '24',
|
'eol' => '24',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'lenovoi5.png',
|
'image' => 'lenovoi5.png',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -146,6 +155,7 @@ $factory->state(App\Models\AssetModel::class, 'optiplex-model', function ($faker
|
||||||
'eol' => '24',
|
'eol' => '24',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'optiplex.jpg',
|
'image' => 'optiplex.jpg',
|
||||||
|
'fieldset_id' => 2,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -224,6 +234,7 @@ $factory->state(App\Models\AssetModel::class, 'iphone6s-model', function ($faker
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 3,
|
'depreciation_id' => 3,
|
||||||
'image' => 'iphone6.jpg',
|
'image' => 'iphone6.jpg',
|
||||||
|
'fieldset_id' => 1,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -235,6 +246,7 @@ $factory->state(App\Models\AssetModel::class, 'iphone7-model', function ($faker)
|
||||||
'eol' => '12',
|
'eol' => '12',
|
||||||
'depreciation_id' => 1,
|
'depreciation_id' => 1,
|
||||||
'image' => 'iphone7.jpg',
|
'image' => 'iphone7.jpg',
|
||||||
|
'fieldset_id' => 1,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,39 @@ $factory->define(App\Models\CustomField::class, function (Faker\Generator $faker
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
$factory->define(App\Models\CustomFieldset::class, function (Faker\Generator $faker) {
|
$factory->state(App\Models\CustomField::class, 'imei', function ($faker) {
|
||||||
return [
|
return [
|
||||||
'name' => $faker->catchPhrase,
|
'name' => 'IMEI',
|
||||||
'user_id' => Auth::id()
|
'help_text' => 'The IMEI number for this device.',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$factory->state(App\Models\CustomField::class, 'phone', function ($faker) {
|
||||||
|
return [
|
||||||
|
'name' => 'Phone Number',
|
||||||
|
'help_text' => 'Enter the phone number for this device.',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$factory->state(App\Models\CustomField::class, 'ram', function ($faker) {
|
||||||
|
return [
|
||||||
|
'name' => 'RAM',
|
||||||
|
'help_text' => 'The amount of RAM this device has.',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$factory->state(App\Models\CustomField::class, 'cpu', function ($faker) {
|
||||||
|
return [
|
||||||
|
'name' => 'CPU',
|
||||||
|
'help_text' => 'The speed of the processor on this device.',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$factory->state(App\Models\CustomField::class, 'mac-address', function ($faker) {
|
||||||
|
return [
|
||||||
|
'name' => 'MAC Address',
|
||||||
|
'help_text' => 'regex:/^[0-9]{15}$/',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
23
database/factories/CustomFieldsetFactory.php
Normal file
23
database/factories/CustomFieldsetFactory.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$factory->define(App\Models\CustomFieldset::class, function (Faker\Generator $faker) {
|
||||||
|
return [
|
||||||
|
'name' => $faker->catchPhrase,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$factory->state(App\Models\CustomFieldset::class, 'mobile', function ($faker) {
|
||||||
|
return [
|
||||||
|
'name' => 'Mobile Devices',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$factory->state(App\Models\CustomFieldset::class, 'computer', function ($faker) {
|
||||||
|
return [
|
||||||
|
'name' => 'Laptops and Desktops',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,40 @@ class CustomFieldSeeder extends Seeder
|
||||||
CustomField::truncate();
|
CustomField::truncate();
|
||||||
CustomFieldset::truncate();
|
CustomFieldset::truncate();
|
||||||
DB::table('custom_field_custom_fieldset')->truncate();
|
DB::table('custom_field_custom_fieldset')->truncate();
|
||||||
factory(CustomField::class, 4)->create();
|
|
||||||
|
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'
|
||||||
|
],
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,22 +9,5 @@ class SupplierSeeder extends Seeder
|
||||||
Supplier::truncate();
|
Supplier::truncate();
|
||||||
factory(Supplier::class, 5)->create();
|
factory(Supplier::class, 5)->create();
|
||||||
|
|
||||||
$src = public_path('/img/demo/suppliers');
|
|
||||||
$dst = public_path('/uploads/suppliers');
|
|
||||||
|
|
||||||
$del_files = glob($dst."/*.*");
|
|
||||||
|
|
||||||
foreach($del_files as $del_file){ // iterate files
|
|
||||||
if(is_file($del_file))
|
|
||||||
unlink($del_file); // delete file
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$add_files = glob($src."/*.*");
|
|
||||||
foreach($add_files as $add_file){
|
|
||||||
$file_to_copy = str_replace($src,$dst,$add_file);
|
|
||||||
copy($add_file, $file_to_copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue