Search code examples
phplaravellaravel-5laravel-route

how to call two functions by one route in laravel


I want to get 2 functions by 1 route to view

I tried like this but not working

Route::post('prospect', ['ProspectController@store' , 
                         'course_controller@show_details']);

Solution

  • Is this what you are looking for ?

    Route::get('prospect', 'course_controller@show_details');
    Route::post('prospect', 'ProspectController@store');
    

    If you want to show the prospect after it has been stored, why not just return it in ProspectController@store ?

    If you want to follow Restful API design :

     Route::post('prospect', 'ProspectController@store'); // return created prospect here
    
     Route::get('prospect/{id}', 'ProspectController@show');