dqy92287 2014-06-21 04:46
浏览 49
已采纳

如何在Laravel 4中为crud控制器添加新功能?

I'm using Resourceful controller which there are default functions such as index, create, store, show, edit, update and destroy. My question is that how can I add my own function to that controller? For instance I add a function in that controller like this:

class Account extends \Eloquent {
.
.
.
        /**
         * Attempt login.
         * GET /accounts/login
         *
         * @return Response
         */
        public function login()
        {
            //
            echo "You are in login page";
        }

But it seems not work when i enter that url: account/login. This is my route file:

Route::resource('account', 'AccountsController');
  • 写回答

1条回答 默认 最新

  • dongshan1396 2014-06-21 05:14
    关注

    You need to add a separate route for it, and the route needs to come before Laravel generates the routes for the resource controller.

    Route::get('account/login', 'AccountsController@login');
    Route::resource('account', 'AccountsController');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)