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 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办