Laravel Api post request redirect back to external url
Hi all!
I am trying to create an API that allows me to make a contact form on another site and then send a post request to my API URL that stores the info in a database and generates an email.
The problem I am having is that when the person submits the form, they go to the api's URL and stay there instead of remaining on the external website with a success message.
How can I fix this?
controller
/*
* API Landing Page Email Form
*/
public function lpContact(Request $request)
{
Mail::send('email.lpform', ['request' => $request], function ($m) use ($request) {
$m->from('[email protected]', 'User Name');
$m->to('[email protected]', 'John')->subject('Inquiry from Landing Page' );
});
// Return back to external landing page with success data
return 'Success, Your message has been sent.';
}