Home > database >  Redirect to another route in laravel with parameters
Redirect to another route in laravel with parameters

Time:12-27

i want to riderct from this route

Route::get('/course/{name}', [App\Http\Controllers\FrontEndController::class, 'programoverviewcourse'])->name('programoverviewcourse');   

to this

Route::get('/programoverview/{id}/{name}', [App\Http\Controllers\FrontEndController::class, 'programoverview'])->name('programoverview');

i used this code in controller..but its shows error

return redirect()->route('programoverview', array('id' =>$id,'name'=>$name));

i tried my level best ..but not getting

CodePudding user response:

Using URL with a global redirect helper function

return redirect ('states/'.$id.'/regions')->with ('message', 'State saved correctly!!!');

Using named route

return redirect ()->route ('regions', ['id' => $id])->with ('message', 'State saved correctly!!!');

Using controller action

return redirect ()->action ('RegionController@index', ['id' => $id])->with ('message', 'State saved correctly!!!');

CodePudding user response:

try this..

return redirect()->route('programoverview', ['id' => $id, 'name' => $name]);
  • Related