您好,欢迎来到花图问答。
搜索
您的当前位置:首页Laravel中的路由2

Laravel中的路由2

来源:花图问答

访问控制器中的方法

Route::get('/user', 'UsersController@index');

重定向路由

Route::redirect('/here', '/there', 301);

 

视图路由

Route::view('/welcome', 'welcome');

 

向路由中传入一个数组

数组中的数据可以传递给视图

Route::view('/welcome', 'welcome', ['name' => 'Taylor']);

URL 中捕获用户的 ID,可以通过定义路由参数来执行

Route::get('user/{id}', function ($id) {

    return 'User '.$id;

});

也可以根据需要在路由中定义多个参数:

Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {

    //

});

 

转载于:https://www.cnblogs.com/CWJDD/p/11463178.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务