Laravel initial router, how to pass the controller?

你说的曾经没有我的故事 提交于 2019-12-11 12:52:01

问题


Mrs. good morning I'd like to config my Laravel initial route, to works on the /, I don't know how I can to do to use the controller.

I use at this moment redirecting my initial route to /start route, but I'd like to use on / only.

See my router below.

Route::controller("Start");
Route::controller("Search");
Route::controller("Contact");

Route::get('/', function()
{
    return Redirect::to("start");
});

I'd like to make:

Route::get('/', function()
{
    return View::make("start.index");
});

And pass the Start.php controller to this view, it's possible?

Can somebody help me with?


回答1:


Route::get('/', 'StartController@index');

looks like what you're after: https://laravel.com/docs/5.2/routing

You can also call it using an array, to pass additional params:

Route::get('/', ['as' => 'start', 'uses' => 'StartController@index']);


来源:https://stackoverflow.com/questions/37859953/laravel-initial-router-how-to-pass-the-controller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!