You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API Endpoint: Develop a single API endpoint /api/submit that accepts a POST
request with the following JSON payload structure:
{
"name": "John Doe",
"email": "john.doe@example.com",
"message": "This is a test message"
}
Validate the data (ensure name', email and message are present).
Database setup: Use Laravel migrations to create a table named
submissions with columns for id, name, email, message
and timestamps (creayed_at and updated_at).
Job Queue: Upon receiving the API request, the data should
not be immediately saved to the database. Instead, dispatch a Laravel job to process the data.
The job should perform the following tasks:
Save the data to the submissions table in the database.
Events: After the data is successfully saved to the database,
trigger a Laravel event named SubmissionSaved. Attach a listener to this event
that logs a message indicating a successful save, including name and email of the submission.
Error handling: Implement error handling for the API to respond with appropriate messages
and status codes for the following scenarios:
Invalid data input (e.g., missing required fields).
Any errors that occur during the job processing.
Documentation: Briefly document the following in a README file:
Instructions on setting up the project and running migrations.
A simple explanation of how to test the API endpoint.