Add support for tracking last submitted form and booking object
- Introduced `last_submitted_form` and `form_submission` properties in the `form` class to retain details of the most recently submitted form. - Updated form submission logic to assign `booking_object` where applicable. - Enhanced response in `formRoute.php` to include booking data when available.
This commit is contained in:
@@ -14,6 +14,7 @@ use forms\objects\book_interior_wash_f;
|
||||
use forms\objects\book_wash_f;
|
||||
use forms\objects\complete_booking_f;
|
||||
use forms\objects\generate_booking_wash_certificate_f;
|
||||
use objects\form_submissions_o;
|
||||
use traits\form_t;
|
||||
|
||||
/** Require the forms using glob */
|
||||
@@ -40,6 +41,8 @@ class form
|
||||
* @var complete_booking_f $complete_booking_without_wash_certificate The COMPLETE_BOOKING_WITHOUT_WASH_CERTIFICATE form
|
||||
*/
|
||||
public complete_booking_f $complete_booking_without_wash_certificate;
|
||||
public $last_submitted_form;
|
||||
public form_submissions_o $form_submission;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -59,6 +62,8 @@ class form
|
||||
{
|
||||
/** @var form_t|object $form */
|
||||
$form->submit();
|
||||
$this->last_submitted_form = $form;
|
||||
$this->form_submission = $form->form_submissions_o;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ use traits\form_t;
|
||||
class book_wash_f extends form_helper_c
|
||||
{
|
||||
use form_t;
|
||||
public ?bookings_o $booking_object = null;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
@@ -100,6 +101,7 @@ class book_wash_f extends form_helper_c
|
||||
$email->sendBookingConfirmationEmail(
|
||||
$bookings->id,
|
||||
);
|
||||
$this->booking_object = $bookings;
|
||||
// TODO: Implement afterSubmit() method.
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class formRoute
|
||||
);
|
||||
|
||||
$response->success(
|
||||
'Form submitted successfully'
|
||||
(isset($form->last_submitted_form->booking_object)) ? $form->last_submitted_form->booking_object->asArray() : $form->form_submission->asArray()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user