2017-10-17 175 views
0

我已經得到了以下請求驗證:Laravel不驗證

<?php 

namespace App\Http\Requests; 

use Illuminate\Foundation\Http\FormRequest; 

class OwnerEstate extends FormRequest 
{ 
    /** 
    * 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 [ 
      'firstname' => 'required_if:type,individual', 
      'secondname'=> 'required_if:type,individual', 
      'lastname' => 'required_if:type,individual', 
      'pin' => 'required_if:type,individual|digits:10', 

      'name' => 'required_if:type,legal-entity', 
      'eik' => 'required_if:type,legal-entity|digits:9' 
     ]; 
    } 
} 

而當類型不是個別它仍然會檢查「位數:10」驗證引腳並返回錯誤。如果required_if驗證不需要該字段,如何禁用其他驗證。 (我正在使用Laravel 5.5)

回答