您好我现在一直在使用隐式控制器,但今天我遇到了一个我无法理解的问题,我在 Route.php 中有以下内容:
/**
* Purchase
*/
Route::controllers([
'purchase' => 'PurchaseController'
]);
在我的控制器中我创建了这个方法:
public function postNsano(NsanoRequest $request)
{
$data = [
'code' => $request->code,
'msg' => $request->msg,
'reference' => $request->referencecode
];
if ($request->code == "00")
{
Session::put('nsano_callback_post_data', $data);
return [
'code' => '00',
'msg' => 'success'
];
}
else
{
return [
'code' => '01',
'msg' => 'rollback'
];
}
}
现在出于某种原因,当我尝试发布到此网址时: sample.com/purchase/nsano
我收到此错误:“找不到控制器方法” 这对我来说很奇怪,因为我可以在那里看到方法。
我取出了$ request并且只使用了Input :: get(),现在它的工作原理有人可以向我解释一下吗?
这是我的要求:
class NsanoRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'code' => 'required',
'msg' => 'required',
'reference' => 'required'
];
}
}
答案 0 :(得分:1)
隐式控制器路由需要方法名称中的HTTP谓词:
public function postNsano(NsanoRequest $request)
{
//
}
答案 1 :(得分:0)
您的请求验证不正确,因此它跳转到网址以提示错误但未找到。 如果你添加一些这样的参数而不是OK。