2017-04-14 78 views
0

我在我的laravel 5.3项目中使用了这段代码,但它说它是badcallmethodexception,我发现控制器方法在新版本中不再可用,如何编写此代码? 这是我的代码:控制器方法的替代方案

Route::controller('notifications', 'NotificationController'); 

该控制器内部有这样的代码:

public function getIndex() 
{ 
    return view('notification'); 
} 

public function postNotify(Request $request) 
{ 
    $notifyText = e($request->input('notify_text')); 


} 

回答

0

如果你不使用默认的laravel控制器方法您需要定义哪种方法应该被称为路由。

Route::get('notifications', '[email protected]'); 
Route::post('notifications', '[email protected]'); 
+0

为我工作的感谢! –

0

写路线为:

Route::post('notification','[email protected]'); 

这里是,你可以使用方法类型根据您的要求。否则,你可以使用资源作为

Route::resource('notification','NotificationController'); 

资源只能索引,创建,存储,更新和销毁方法一起使用。

Laravel文件:https://laravel.com/docs/5.3/controllers#resource-controllers

+0

感谢您的回答 –