polisplexity.tech/app/Services/FormService.php

23 lines
591 B
PHP

<?php
namespace App\Services;
use Illuminate\Support\Facades\Storage;
class FormService {
private $basePath = 'app/json/forms/';
public function getFormFields($formName) {
$filePath = $this->basePath . $formName . '.json';
return $this->loadJsonData($filePath);
}
private function loadJsonData($filePath) {
$fullPath = storage_path($filePath);
if (!file_exists($fullPath)) {
throw new \Exception("JSON file for form configuration not found.");
}
return json_decode(file_get_contents($fullPath), true);
}
}