3a703 admin edit submission (#305)
* wip: admin submission edit feature * wip: refresh form submission after update * wip: connect submissions page data to store * Fixed the submission loading issue * test: admin edit submission feature test * Fix pending submission, editabe submission & more (#306) --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -6,7 +6,11 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\FormSubmissionResource;
|
||||
use App\Models\Forms\Form;
|
||||
use App\Exports\FormSubmissionExport;
|
||||
use App\Http\Requests\AnswerFormRequest;
|
||||
use App\Jobs\Form\StoreFormSubmissionJob;
|
||||
use App\Models\Forms\FormSubmission;
|
||||
use App\Service\Forms\FormSubmissionFormatter;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
@@ -27,6 +31,20 @@ class FormSubmissionController extends Controller
|
||||
return FormSubmissionResource::collection($form->submissions()->paginate(100));
|
||||
}
|
||||
|
||||
public function update(AnswerFormRequest $request, $id, $submissionId)
|
||||
{
|
||||
$form = $request->form;
|
||||
$this->authorize('update', $form);
|
||||
$job = new StoreFormSubmissionJob($request->form, $request->validated());
|
||||
$job->setSubmissionId($submissionId)->handle();
|
||||
|
||||
$data = new FormSubmissionResource(FormSubmission::findOrFail($submissionId));
|
||||
return $this->success([
|
||||
'message' => 'Record successfully updated.',
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(string $id)
|
||||
{
|
||||
$form = Form::findOrFail((int) $id);
|
||||
|
||||
Reference in New Issue
Block a user