コード例 #1
0
 /**
  * Interpolate model attribute values on validation rules.
  *
  * @param  array $rules
  * @param  array $model
  * @return array
  */
 protected function interpolateValidationRules($rules, $model)
 {
     foreach ($rules as &$rule) {
         $attrs = last(chars_within($rule, ['{', '}']));
         foreach ($attrs as $attr) {
             $rule = str_replace('{' . $attr . '}', is_null($model[$attr]) && $attr == $this->model->getKeyName() ? 'NULL' : $model[$attr], $rule);
         }
     }
     return $rules;
 }
コード例 #2
0
ファイル: Transformer.php プロジェクト: sedp-mis/lib
 public function cleanTransformationRule($transformationRule)
 {
     $transformationRule = ltrim($transformationRule);
     $holders = explode(' ', static::OPTION_HOLDER);
     $specialOptions = chars_within($transformationRule, $holders);
     if (count(head($specialOptions)) == 0) {
         return $transformationRule;
     }
     foreach (head($specialOptions) as $index => $specialOption) {
         $transformationRule = str_replace($specialOption, $optKey = "{opt_{$index}}", $transformationRule);
         $this->specialOptions[$optKey] = $specialOption;
     }
     return $transformationRule;
 }