0
我正在学习Laravel 5.2。我正在尝试做一个表单验证example.Have阅读文档的验证和我的代码使用创建和存储方法使用验证请求类正在工作。现在我试图用相同的方法同时执行POST
和GET
。我创建了我request
类,我的规则方法定义为这个Laravel 5.2,为POST方法设置验证,而不是GET
public function rules()
{
if($this->method() == 'POST'){
return [
'first_name' => 'required'
];
}else{
return [];
}
}
为
public function create(myRequest $request){
//save and display the data
}
,但是当我打开我的方法,我得到一个空白页说我的控制器方法声明,forbidden
。我尝试为GET返回null
值,但它不起作用。
Argument 2 passed to Illuminate\Validation\Factory::make()
must be of the type array, null given
不可能做这样的事情吗?