Skip to content

Commit

Permalink
Merge pull request #143 from wri/TM-782_export_landscapes
Browse files Browse the repository at this point in the history
TM-782 fix: change framework reference for exporting
  • Loading branch information
cesarLima1 authored Apr 15, 2024
2 parents cf20fce + 2f20ad9 commit cfc3c5a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]);

Expand All @@ -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)
Expand Down

0 comments on commit cfc3c5a

Please sign in to comment.