/**
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function getValidatorInstance()
 {
     $validator = parent::getValidatorInstance();
     // 写真のバリデーション
     $validator->each('picture', 'image');
     $pictureKeys = $this->getPictureKeys();
     $attributeNames = [];
     foreach ($pictureKeys as $key) {
         $attributeNames['picture.' . $key] = label('picture');
     }
     $validator->setAttributeNames($attributeNames);
     $validator->after(function ($validator) use(&$pictureKeys) {
         $messages = $validator->messages();
         foreach ($pictureKeys as $key) {
             if ($messages->has('picture.' . $key)) {
                 // BootFormで表示できるよう、pictureにメッセージをコピー
                 $validator->errors()->add('picture', $messages->first('picture.' . $key));
                 return;
             }
         }
     });
     return $validator;
 }
Example #2
0
 /**
  * Validate custom
  *
  * @author Dung Le
  * @return object validate
  */
 public function getValidatorInstance()
 {
     // do validate
     $validator = parent::getValidatorInstance();
     // callback validate
     $validator->after(function ($validator) {
         // some extends check
         $this->validateCustom($validator);
     });
     return $validator;
 }