Laravel初始路由器,如何通过控制器? [英] Laravel initial router, how to pass the controller?

查看:101
本文介绍了Laravel初始路由器,如何通过控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

太太.早上好,我想配置我的Laravel初始路线,以在/上工作,我不知道该怎么做才能使用控制器.

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.

此刻我使用将我的初始路由重定向到/start路由,但我只想在/上使用.

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");
});

我想做:

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

然后将Start.php控制器传递给此视图,这可能吗?

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

有人可以帮我吗?

推荐答案

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

看起来像您所追求的: https://laravel.com/docs/5.2/routing

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']);

这篇关于Laravel初始路由器,如何通过控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆