是否可以在单个控制器中使用 2 个不同的 FormRequest 验证,一个用于store,另一个用于index,如何?
我曾经method()从 中返回不同的验证rules(),例如:
public function rules()
{
if($this->method() == 'GET')
{
return [
'customer' => 'required|numeric',
];
}
if($this->method() == 'POST')
{
return [
'author' => 'required|numeric',
];
}
}
但看起来很不舒服