<?php

namespace Database\Seeders\Objects;

use App\Models\Objects\ObjectType;
use Illuminate\Database\Seeder;

class ObjectsTableSeeder extends Seeder {
    public array $objects = [
    ];

    public function run() {
        collect($this->objects)->each(function($data, $name) {
            $objectType = ObjectType::query()->where(['name' => $data['type']])->firstOrFail();
            $object = $objectType->objects()->firstOrCreate(['name' => $name]);
            $object->setValues($data['properties'] ?? []);
        });
    }
}
