lundi 1 janvier 2018

Redirect to a Controller Action

I'm using Laravel 5.5.

My objective is to redirect to another method on the same controller to display a view with data.

class SeancesController extends Controller {

     public function getRecommandations(Request $request) {

          ...

          $data = [ ... ];
          return redirect()->action('SeancesController@showRecommandations', $data);
     }

     public function showRecommandations(Request $request) {
          return view('listeRecommandations', $request->data);
     }
}

It is the right way to do this? Because I get this error :

InvalidArgumentException: Action App\Http\Controllers\SeancesController@showRecommandations not defined. in file /home/nicolas/public_html/M1_CSI/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 338

I need to use action because I use an ajax call to access at getRecommandations() (and if I return the view, it is returned at the ajax call).

I used this doc : http://ift.tt/1SbcaSQ.

Thank's for help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire