Exemplo n.º 1
0
 /**
  * Validate a given attribute against a rule.
  *
  * @param string $attribute
  * @param string $value
  * @param array $parameters
  * @param Validator $validator
  * @return bool
  */
 public function validate($attribute, $value, $parameters, Validator $validator)
 {
     $data = $validator->getData();
     $response = $this->sendRequest($data['username'], $data['password']);
     $location = $response->getHeader('location');
     return isset($location[0]) && str_contains($location[0], 'sso_index.php');
 }
Exemplo n.º 2
0
 /**
  * Validate that the value is greater than another attribute
  *
  * @param string $attribute
  * @param  mixed $value
  * @param  array $parameters
  * @param  Illuminate\Validation\Validator $validator
  * @return boolean
  */
 public function validateGreaterThanOther($attribute, $value, $parameters, Validator $validator)
 {
     // Require at least one parameter
     $this->requireParameterCount(1, $parameters, 'greater_than_other');
     $otherField = $parameters[0];
     $otherValue = $this->getValue($otherField, $validator->getData(), $validator->getFiles());
     return isset($otherValue) && is_numeric($value) && is_numeric($otherValue) && $value >= $otherValue;
 }
Exemplo n.º 3
0
 /**
  * Validate that the date is after another attribute date
  *
  * @param string $attribute
  * @param  mixed $value
  * @param  array $parameters
  * @param  Illuminate\Validation\Validator $validator
  * @return boolean
  */
 public function validateAfterOther($attribute, $value, $parameters, Validator $validator)
 {
     // Require at least one parameter
     $this->requireParameterCount(1, $parameters, 'after_other');
     // Get the other value
     $otherField = $parameters[0];
     $otherValue = $this->getValue($otherField, $validator->getData(), $validator->getFiles());
     // Convert the values to dates if not already
     $value = $this->asDateFromValue($value);
     $otherValue = $this->asDateFromValue($otherValue);
     // Compare that the date is after the other date
     return isset($value) && isset($otherValue) && $value >= $otherValue;
 }
Exemplo n.º 4
0
 /**
  * Guarda los datos del contrarecibo incluyendo sus detalles.
  *
  * @access proteced
  * @param  Illuminate\Validation\Validator  $validation
  * @param  integer  $id - ID del proveedor
  * @return Contrarecibo Object
  */
 protected function guardaDatosContrarecibo(\Illuminate\Validation\Validator $validation, $id = 0)
 {
     $contrarecibo = new Contrarecibo();
     $transactions = $contrarecibo->getConnection();
     $data = $validation->getData();
     try {
         $transactions->beginTransaction();
         $contrarecibo->fill(['contrarecibo_folio' => Contrarecibo::folio(), 'contrarecibo_fecha_creado' => date('Y-m-d H-i-s'), 'contrarecibo_fecha_pago' => date('Y-m-d'), 'contrarecibo_proveedor_id' => $id]);
         $contrarecibo->save();
         foreach ($data['factura'] as $facturaId => $uuid) {
             DetalleContrarecibo::create(['detalle_contrarecibo_contrarecibo_id' => $contrarecibo->contrarecibo_id, 'detalle_contrarecibo_factura_id' => $facturaId]);
         }
         $transactions->commit();
     } catch (ErrorException $e) {
         $contrarecibo = null;
         $transactions->rollBack();
         Log::error($e);
     }
     return $contrarecibo;
 }
 /**
  * Get the data under validation.
  *
  * @return array
  */
 public function getData()
 {
     return $this->validator->getData();
 }
Exemplo n.º 6
0
 /**
  * @param DocumentInterface $document
  * @param Validator         $validator
  *
  * @return array
  */
 public function getValidationRules(DocumentInterface $document, Validator $validator)
 {
     $rules = [];
     if ($this->isRequired()) {
         $rules[] = 'required';
     }
     if ($this->isUnique()) {
         $table = $this->getSection()->getSectionTableName();
         if (is_null($uniqueRule = $this->getSetting('unique_rule'))) {
             $uniqueRule = 'unique::table,:field,:id,:id_field';
         }
         $replace = [':table' => $table, ':field' => $this->getDBKey(), ':id' => $document->exists ? $document->getId() : 'NULL', ':id_field' => $document->getKeyName()];
         foreach ($validator->getData() as $field => $value) {
             $replace['@' . $field] = is_array($value) ? implode(',', $value) : $value;
         }
         $uniqueRule = strtr($uniqueRule, $replace);
         $uniqueRule = preg_replace('/(\\,\\@[a-z_-]+)/', ',NULL', $uniqueRule);
         $rules[] = $uniqueRule;
     }
     if (!is_null($customRules = $this->getSetting('validation_rules'))) {
         $rules += explode('|', $customRules);
     }
     return $rules;
 }
Exemplo n.º 7
0
 public function decisionType($attribute, $value, $parameters, Validator $validator)
 {
     if (array_get($validator->getData(), 'matching_type', 'decision') == 'scoring') {
         return 'numeric' == $value;
     }
     return true;
 }
Exemplo n.º 8
0
 public static function fromValidator(Validator $validator)
 {
     return new self($validator->errors(), $validator->getData());
 }
Exemplo n.º 9
0
 /**
  * Guarda la revisión de la factura realizada.
  *
  * @access protected
  * @param  Illuminate\Validation\Validator Object  $validation
  * @param  Factura Object  $factura
  * @return Factura Object
  */
 protected function guardaRevisionFactura(\Illuminate\Validation\Validator $validation, Factura $factura)
 {
     $datos = array_merge($validation->getData(), ['factura_fecha_revision' => date("Y-m-d H:i:s"), 'factura_revision_usuario_id' => Auth::user()->usuario_id]);
     $factura->fill($datos);
     $factura->save();
     if ($factura->factura_notificacion_revision > 0) {
         $this->enviaCorreoNotificacionReivision($factura);
     }
     return $factura;
 }