Laravel 13 + Livewire/Volt app for managing client organizations, documents, passwords, flexible assets, virtual machines, contacts, domains, todos, shortcuts, and role-based user administration.
65 lines
2.6 KiB
PHP
65 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\FlexibleAssetType;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class AssetTypeLookupSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Ready-to-use asset types covering common IT inventory categories,
|
|
* with the fields a "Configuration" record used to carry.
|
|
*/
|
|
const TYPES = [
|
|
['name' => 'Poste de travail', 'icon' => '💻'],
|
|
['name' => 'Serveur', 'icon' => '🖧'],
|
|
['name' => 'Équipement réseau', 'icon' => '📡'],
|
|
['name' => 'Téléphone', 'icon' => '📱'],
|
|
['name' => 'NAS', 'icon' => '🗄️'],
|
|
['name' => 'Switch', 'icon' => '🔀'],
|
|
['name' => 'Wifi', 'icon' => '📶'],
|
|
['name' => 'Sauvegarde', 'icon' => '💾'],
|
|
['name' => 'Autre', 'icon' => '🔧'],
|
|
];
|
|
|
|
const FIELDS = [
|
|
['label' => 'Nom d\'hôte', 'field_type' => 'text', 'show_in_list' => true],
|
|
['label' => 'Adresse IP', 'field_type' => 'text', 'show_in_list' => true],
|
|
['label' => 'Adresse MAC', 'field_type' => 'text'],
|
|
['label' => 'Numéro de série', 'field_type' => 'text'],
|
|
['label' => 'Fabricant', 'field_type' => 'text'],
|
|
['label' => 'Modèle', 'field_type' => 'text'],
|
|
['label' => 'Système d\'exploitation', 'field_type' => 'text'],
|
|
['label' => 'Statut', 'field_type' => 'select', 'options' => ['choices' => ['Actif', 'Inactif', 'Retiré']], 'show_in_list' => true],
|
|
['label' => 'Site', 'field_type' => 'related_asset', 'options' => ['target' => 'location']],
|
|
['label' => 'Contact', 'field_type' => 'related_asset', 'options' => ['target' => 'contact']],
|
|
['label' => 'Date d\'installation', 'field_type' => 'date'],
|
|
['label' => 'Fin de garantie', 'field_type' => 'date'],
|
|
['label' => 'Notes', 'field_type' => 'textarea'],
|
|
];
|
|
|
|
public function run(): void
|
|
{
|
|
foreach (self::TYPES as $typeAttributes) {
|
|
$type = FlexibleAssetType::firstOrCreate(['name' => $typeAttributes['name']], $typeAttributes);
|
|
|
|
if ($type->fields()->exists()) {
|
|
continue;
|
|
}
|
|
|
|
foreach (self::FIELDS as $index => $field) {
|
|
$type->fields()->create([
|
|
'name' => \Illuminate\Support\Str::snake($field['label']),
|
|
'label' => $field['label'],
|
|
'field_type' => $field['field_type'],
|
|
'options' => $field['options'] ?? null,
|
|
'is_required' => false,
|
|
'show_in_list' => $field['show_in_list'] ?? false,
|
|
'sort_order' => $index,
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|