方法控制器不存在。 [英] Method controller does not exist.

查看:781
本文介绍了方法控制器不存在。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我已经使用这种格式了。在我的routes.php我有

So I have used this format again. In my routes.php I have

Route::controller('datatables', 'HomeController', [
    'PaymentsData'  => 'payments.data',
    'getIndex' => 'datatables',
]);

在我的HomeController.php中,我有

In my HomeController.php I have

  public function getIndex()
    {
        return view('payments.index');
    }

    /**
     * Process datatables ajax request.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function Payments()
    {
        return Datatables::of(DB::table('customer'))->make(true);
    }

每当我尝试 php artisan 我得到 [BadMethodCallException]方法控制器不存在。

问题,是这种形式或为什么有人发现了什么问题?请帮忙。谢谢。

Question, is this form of doing it Deprecation or why anyone spot something wrong? Kindly assist. Thank you.

推荐答案

据我所知,从来没有Laravel 5。我不知道在5之前。但在5,你需要使用 Route :: get Route :: post

As far as I'm aware that's never been available for Laravel 5. I haven't used 4 so I'm not sure about prior to 5. But in 5 you need to use Route::get and Route::post.

Route::get('datatables', ['as' => 'HomeController', 'uses' => 'HomeController@getIndex']);
Route::get('payments-data', ['as' => 'HomeControllerPaymentsData', 'uses' => 'HomeController@Payments']);

是的,它被删除,因为使用隐式控制器是不好的做法 - https://github.com/illuminate/routing/commit/772fadce3cc51480f25b8f73065a4310ea27b66e#diff-b10a2c4107e225ce309e12087ff52788L259

Yep, it was removed as using implicit controllers is bad practice - https://github.com/illuminate/routing/commit/772fadce3cc51480f25b8f73065a4310ea27b66e#diff-b10a2c4107e225ce309e12087ff52788L259

这篇关于方法控制器不存在。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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