getContents(), true); $categoryName = $template['category'] ?? 'Default'; if (isset($template['file'])) { $template['prompt'] = File::get($file->getPath() . '/' . $template['file']); } $category = TemplateCategory::query()->firstOrCreate([ 'name' => $categoryName, ], [ 'name' => $categoryName, ]); $category->templates()->firstOrCreate([ 'slug' => $template['slug'], ], [ 'name' => $template['name'], 'type' => $template['type'], 'description' => $template['description'], 'prompt' => $template['prompt'], 'option' => $template['option'] ?? null, 'capabilities' => $template['capabilities'] ?? [], 'enabled' => $template['enabled'] ?? true, ]); } } }