I'm trying to build a page with two forms, both are set method="post"
, as well as a submit <button>
for each form. The submit action of first form is handled by FirstController
, and the second one is handled by SecondController
. In the route file web.php
, I need to declare two route functions for each submit button, and I want to keep the same url, but there is no way the button will know which post it should call. I saw some solutions about creating jobs to handle each button, but anyway can I tell Laravel which post route to call?
The skeleton is like this:
web.php
Route::post('/', 'FirstController@store');
Route::post('/', 'SecondController@sendEmail');
FirstController.php
class FirstController extends Controller
{
public function store()
{
/*
create a new entry to the data base
*/
}
}
SecondController.php
class SecondController extends Controller
{
public function sendEmail()
{
Mail::to('recipient@abc.com')->send(new SampleMail());
}
}
/
when you're done. – ceejayoz/
. – ceejayoz