true, 'path_pattern' => '', 'file_pattern' => '{timestamp}_{file_name}' ]; } else { return null; } } // Get the main path setting $mainPath = setting('inspection_history_main_path', false, ''); // If no main path is set, return null (feature not configured) if (empty($mainPath)) { return null; } // Get module title if not provided if (empty($moduleTitle)) { $module = \App\Types::where('slug', $moduleSlug)->first(['title']); $moduleTitle = $module ? $module->title : $moduleSlug; } // Clean module title for use as directory name $cleanTitle = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $moduleTitle); $cleanTitle = preg_replace('/_+/', '_', $cleanTitle); $cleanTitle = trim($cleanTitle, '_'); // Build the full path: main_path/module_title $fullPath = $mainPath . '/' . $cleanTitle; return [ 'path' => $fullPath, 'path' => $fullPath, 'path_pattern' => $moduleConfig['path_pattern'] ?? null, 'file_pattern' => $moduleConfig['file_pattern'] ?? $moduleConfig['pattern'] ?? null, 'pattern' => $moduleConfig['pattern'] ?? null, // Keep for backward compatibility elsewhere if needed 'active' => $moduleConfig['active'] ?? false ]; }