Laravel 5.7 | Multiple post metods in one view

Posted 1 week ago by ziben69

Hello guys, how can I handle multiple post metods. I have something like this:

Routes:

Route::get('business/create','[email protected]')->middleware('auth');
Route::post('business/', '[email protected]')->middleware('auth');
Route::get('business/createDoctor','[email protected]')->middleware('auth');
Route::post('business/', '[email protected]')->middleware('auth');

View:

<div class="row">
        <div class="col-lg-6">
                  <a href="{{ URL::to('business/create') }}">Add Element</a>
       </div>
       <div class="col-lg-6">
                  <a href="{{ URL::to('business/createDoctor') }}">Add Doctor</a>
       </div>
</div>

BusinessController:

 public function create()
    {
        return view('pages.business.create');
    }
 public function store(Request $request)
    {
        $business = Business::create($request->all());
        return redirect()->action('[email protected]');
    }
public function createDoctor()
    {
        return view('pages.business.createDoctor');
    }
public function storeDoctor(Request $request)
    {
        $business = Business::create($request->all());
        return redirect()->action('[email protected]');
    }

And I have a problem with many post methods. One works, the second throws a error:

Action App\Http\Controllers\[email protected] not defined.

is there any way to fix it? So much thanks!

Please sign in or create an account to participate in this conversation.