简体   繁体   English

Laravel 4控制器,处理默认路由?

[英]Laravel 4 Controllers, handling default route?

Let's say I have a UsersController . 假设我有一个UsersController In that controller there is a handler for website.com/users/login and website.com/users/register 在该控制器中,有一个用于处理website.com/users/loginwebsite.com/users/register的处理程序

How would I handle a route of website.com/users within the controller similarly how I would with the other handlers? 我将如何在控制器内处理website.com/users的路由,与其他处理程序类似?

In routes.php: 在routes.php中:

Route::controller('users', 'UserController');

In UserController.php: 在UserController.php中:

class UserController extends BaseController {

    public function getIndex()
    {
        # GET website.com/users 
    }

    public function getLogin()
    {
        # GET website.com/users/login   
    }

    public function getRegister()
    {
        # GET website.com/users/register    
    }

}

The Laravel docs have more examples: http://four.laravel.com/docs/routing Laravel文档有更多示例: http ://four.laravel.com/docs/routing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM