1

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']);
Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
Jazim Max
  • 111
  • 1
  • 10

3 Answers3

3

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');
Mike
  • 552
  • 3
  • 18
0

better to used redirect to controller action

try this way
Route::post('prospect', 'ProspectController@store'); //use only one method 

now add in line in ProspectController in store method if you want to use redirect method

   return redirect()->action('HomeController@index');

otherwise use call method only like this way..

 app('App\Http\Controllers\course_controller')->show_details();

otherway used like that

 app(course_controller::class)->show_details();

or directly create object like that

(new  App\Http\Controllers\course_controller())->show_details();
Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
0

Try this below code:

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

public function store(Request $request)
{
    if($request->something == 'something'):
       Self::showDetail();
    else:
      // Continue store method

    endif;
}

public static function showDetail(){

}
Mayank Dudakiya
  • 3,635
  • 35
  • 35
Manisha
  • 70
  • 8