Reputation: 75
I am new to Laravel and want to redirect to another view using button. On clicking button I want to redirect to particular route function and then to controller. But I am making some mistake.I did what they showed online but couldn't rectify. Following is my code.
Controller:
class MyController extends BaseController{
function fromSub(){
return view('from');
}
}
Route:
Route::get('from',array('uses'=>'MyController@fromSub' , 'as' => 'from'));
View:
<html>
<body>
<button type="button" onclick="window.location='{{ url("from") }}'">BUTTON</button>
</body>
</html>
Thanks in advance.
Upvotes: 1
Views: 72
Reputation: 4183
replace this code in route and test it:
Laravel 5.1+:
Route::get('from', 'MyController@fromSub')->name('from');
Laravel 5.1 :
Route::get('from', [
'as' => 'from', 'uses' => 'MyController@fromSub'
]);
Upvotes: 1