From 09ca621c93ba5d786be76fbf55cd769d9601c394 Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Mon, 15 Apr 2024 12:28:13 -0400 Subject: [PATCH] TM-782 fix: change framework reference for exporting --- .../V2/Exports/ExportAllMonitoredEntitiesController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/V2/Exports/ExportAllMonitoredEntitiesController.php b/app/Http/Controllers/V2/Exports/ExportAllMonitoredEntitiesController.php index 5104b984c..ded1eb6fa 100644 --- a/app/Http/Controllers/V2/Exports/ExportAllMonitoredEntitiesController.php +++ b/app/Http/Controllers/V2/Exports/ExportAllMonitoredEntitiesController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\V2\Exports; use App\Http\Controllers\Controller; +use App\Models\Framework; use App\Models\V2\Forms\Form; use App\Models\V2\Nurseries\Nursery; use App\Models\V2\Nurseries\NurseryReport; @@ -20,6 +21,7 @@ class ExportAllMonitoredEntitiesController extends Controller public function __invoke(Request $request, string $entity, string $framework) { $modelClass = $this->getModelClass($entity); + $framework = $this->getSlug($framework); $form = $this->getForm($modelClass, $framework); $this->authorize('export', [$modelClass, $form]); @@ -36,6 +38,11 @@ public function __invoke(Request $request, string $entity, string $framework) ]); } + private function getSlug(string $framework) + { + $frameworkModel = Framework::where('access_code', $framework)->firstOrFail(); + return $frameworkModel->slug; + } private function getForm(string $modelClass, string $framework) { return Form::where('model', $modelClass)