在我的Laravel(5.1)项目中,我需要创建一个验证表单的请求.
但是对于这个请求,我想合并两个不同的请求:
第一个要求:
class AdvertisementRequest extends Request {
public function authorize()
{
return true;
}
public function rules()
{
return [
'ads_type' => 'required|numeric|in:0,1',
'category' => 'required|numeric|exists:categories,id',
'title' => 'required|alpha_num|max:45',
'description' => 'required|alpha_num|max:2000',
'price' => 'required|numeric',
];
}
}
Run Code Online (Sandbox Code Playgroud)
第二个要求:
class UserRegisterRequest extends Request {
public function authorize()
{
return true;
}
public function rules()
{
$rules = [
'form_type' => 'required|numeric|in:0,1',
'user_type' => 'required|numeric|in:0,1',
'phone' => 'required|phone_number',
'region' => 'required|numeric|exists:regions,id',
'department' => 'required|numeric|exists:departments,code',
'postal_code' => 'required|postal_code',
'city' => 'alpha|max:45', …Run Code Online (Sandbox Code Playgroud)