move form to another workspace (#339)

* move form to another workspace

* style: apply lint

* fix typo error

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka
2024-03-12 17:55:19 +01:00
committed by GitHub
parent 3aa80b2b75
commit 29fdc961fc
4 changed files with 139 additions and 0 deletions

View File

@@ -218,4 +218,24 @@ class FormController extends Controller
return redirect()->to(Storage::temporaryUrl($path, now()->addMinutes(5)));
}
/**
* Updates a form's workspace
*/
public function updateWorkspace($id, $workspace_id)
{
$form = Form::findOrFail($id);
$workspace = Workspace::findOrFail($workspace_id);
$this->authorize('update', $form);
$this->authorize('view', $workspace);
$form->workspace_id = $workspace_id;
$form->creator_id = auth()->user()->id;
$form->save();
return $this->success([
'message' => 'Form workspace updated successfully.',
]);
}
}