问题描述
所以我已经使用这种格式了。在我的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']);
是的,它被删除,因为使用隐式控制器是不好的做法 -
Yep, it was removed as using implicit controllers is bad practice - https://github.com/illuminate/routing/commit/772fadce3cc51480f25b8f73065a4310ea27b66e#diff-b10a2c4107e225ce309e12087ff52788L259
这篇关于方法控制器不存在。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!