- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Form;
|
|
use App\Models\FormSubmission;
|
|
|
|
/**
|
|
* Service to handle Form creation and Submissions.
|
|
*/
|
|
class FormService
|
|
{
|
|
/**
|
|
* Store a newly created form.
|
|
*
|
|
* @param array $data Data for the new form.
|
|
* @return Form The created form instance.
|
|
*/
|
|
public function storeForm(array $data): Form
|
|
{
|
|
return Form::create($data);
|
|
}
|
|
|
|
/**
|
|
* Update the specified form.
|
|
*
|
|
* @param Form $form The form model to update.
|
|
* @param array $data The new data for the form.
|
|
* @return Form The updated form instance.
|
|
*/
|
|
public function updateForm(Form $form, array $data): Form
|
|
{
|
|
$form->update($data);
|
|
return $form;
|
|
}
|
|
|
|
/**
|
|
* Remove the specified form and its submissions.
|
|
*
|
|
* @param Form $form The form model to delete.
|
|
* @return bool True if successful.
|
|
*/
|
|
public function deleteForm(Form $form): bool
|
|
{
|
|
return (bool) $form->delete();
|
|
}
|
|
|
|
/**
|
|
* Remove a specific form submission.
|
|
*
|
|
* @param FormSubmission $submission The submission to delete.
|
|
* @return bool True if successful.
|
|
*/
|
|
public function deleteSubmission(FormSubmission $submission): bool
|
|
{
|
|
return (bool) $submission->delete();
|
|
}
|
|
}
|