Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如果其他字段没有',则为必填字段;没有具体的价值_Laravel_Laravel 5_Laravel 5.3 - Fatal编程技术网

Laravel 如果其他字段没有',则为必填字段;没有具体的价值

Laravel 如果其他字段没有',则为必填字段;没有具体的价值,laravel,laravel-5,laravel-5.3,Laravel,Laravel 5,Laravel 5.3,我有一个字段项目,如果account\u name字段没有值“0”,则需要该项目。我想在laravel中验证这个场景 eg if account_name = '0' -project_name field is not required if account_name = '1' - project_name field is required $this->validate($request,[ 'project_name'=>'required

我有一个字段项目,如果
account\u name
字段没有值“0”,则需要该项目。我想在laravel中验证这个场景

eg if account_name = '0'  -project_name field is not required 
   if account_name = '1'    - project_name field is required 


 $this->validate($request,[
     'project_name'=>'required_without:account_name,0',
    ]); 

尝试使用
必需\u,除非
!除非account_name等于0,否则名称将是必需的

 $this->validate($request,[
     'project_name'=>'required_unless:account_name,0',
    ]); 

尝试使用
必需\u,除非
!除非account_name等于0,否则名称将是必需的

 $this->validate($request,[
     'project_name'=>'required_unless:account_name,0',
    ]);