I'm trying to pass a variable from a controller to some another controller. I'm doing it like this-
SomeController
public function index(){
$var = 'variable';
return redirect()->route('toAnotherController')->with('var', $var);
}
Route.php
Route::get('/anotherController', 'AnotherController@index')->name('toAnotherController');
Another Controller
public function index(){
echo $var;
}
But, this is giving an error "Undefined variable $var". What is going wrong here? Is there any other way to do this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire