Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TM-782 fix: change framework reference for exporting #143

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading