Skip to content

A free open source IT asset/license management system

Added sync fields to seeders

snipe31ffcc8a8dd6
diff --git a/database/factories/CustomFieldFactory.php b/database/factories/CustomFieldFactory.php
index 6d3268d64d..921404cbfc 100644
--- a/database/factories/CustomFieldFactory.php
+++ b/database/factories/CustomFieldFactory.php
@@ -84,6 +84,48 @@ class CustomFieldFactory extends Factory
});
}
+ public function ipAddress()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'IP Address',
+ 'help_text' => 'The last-known IP address for this device.',
+ ];
+ });
+ }
+
+ public function operatingSystem()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Operating System',
+ 'help_text' => 'The operating system this device is running.',
+ ];
+ });
+ }
+
+ public function osVersion()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'OS Version',
+ 'help_text' => 'The OS version this device is running.',
+ ];
+ });
+ }
+
+ public function lastCheckIn()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Last Check-in',
+ 'help_text' => 'The last time this device was seen by an inventory sync adapter.',
+ 'element' => 'datetime_picker',
+ 'format' => 'DATETIME',
+ ];
+ });
+ }
+
public function testEncrypted()
{
return $this->state(function () {
diff --git a/database/seeders/CustomFieldSeeder.php b/database/seeders/CustomFieldSeeder.php
index f4d76ef331..9e4b14223f 100644
--- a/database/seeders/CustomFieldSeeder.php
+++ b/database/seeders/CustomFieldSeeder.php
@@ -40,6 +40,14 @@ class CustomFieldSeeder extends Seeder
CustomField::factory()->count(1)->testDate()->create();
CustomField::factory()->count(1)->testDatetime()->create();
CustomField::factory()->count(1)->xss()->create();
+ // Fields the Custom HTTP adapter (and other sync adapters)
+ // typically populate. Pre-created so a fresh demo tenant can
+ // wire an adapter's mapping table to real fieldset entries
+ // without hand-creating them first.
+ CustomField::factory()->count(1)->ipAddress()->create();
+ CustomField::factory()->count(1)->operatingSystem()->create();
+ CustomField::factory()->count(1)->osVersion()->create();
+ CustomField::factory()->count(1)->lastCheckIn()->create();
DB::table('custom_field_custom_fieldset')->insert([
[
@@ -155,6 +163,60 @@ class CustomFieldSeeder extends Seeder
'required' => 0,
],
+ // ipAddress, operatingSystem, osVersion, lastCheckIn get
+ // attached to both fieldsets so admins wiring up any sync
+ // adapter can route those pulled values into the same
+ // fields whether the device is a laptop / desktop or a
+ // phone / tablet. xss (id 12) is intentionally left off.
+ [
+ 'custom_field_id' => '13',
+ 'custom_fieldset_id' => '1',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+ [
+ 'custom_field_id' => '13',
+ 'custom_fieldset_id' => '2',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+ [
+ 'custom_field_id' => '14',
+ 'custom_fieldset_id' => '1',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+ [
+ 'custom_field_id' => '14',
+ 'custom_fieldset_id' => '2',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+ [
+ 'custom_field_id' => '15',
+ 'custom_fieldset_id' => '1',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+ [
+ 'custom_field_id' => '15',
+ 'custom_fieldset_id' => '2',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+ [
+ 'custom_field_id' => '16',
+ 'custom_fieldset_id' => '1',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+ [
+ 'custom_field_id' => '16',
+ 'custom_fieldset_id' => '2',
+ 'order' => 0,
+ 'required' => 0,
+ ],
+
]);
}
}