Redirect Route direct to view

Asked

Viewed 680 times

1

I’ve read in some places that the correct thing is to point the way to a controller and then redirect to a view. I do it even when I won’t pass any variable to that view?

In that case, I will have a "about us" page, where there will be only a static text describing the company, it is wrong that the route redirect directly to the view containing the text?

  • If you are using in the route file put Route::get('sobre-nos', function(){ return view(""); });?

1 answer

2


Not wrong, but also not cozy. You can pass when creating the route:

Route::post('/sobre-nos', function(){
     return view('sobrenos');
}

The "correct" would be to call the controller:

Route::post('/sobre-nos', 'SiteController@sobrenos');

And in the controller create the method over:

public function sobrenos(){
     return view('sobrenos')
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.