Greater_than_field Request Laravel

-1

In previous days I asked this question Validation" greater than "or" less than "in the request of laravel to obtain a customized validation in laravel that worked correctly validating two fields, but I would like to know if it is possible to perform this same validation in a multiregistro

I am validating that for each record, the field value paid is not greater than the field value invoice and I am doing it this way:

public function rules()
{    
  $valor = count($this->get('valorFacturaPagoForwardDetalle'));

  for($i = 0; $i < $valor; $i++)
  {
   $validacion['valorPagadoPagoForwardDetalle'.$i] = 'required_with:valorFacturaPagoForwardDetalle'.$i.'|numeric|min:1';

   $validacion['valorFacturaPagoForwardDetalle'.$i] =  'required_with:valorPagadoPagoForwardDetalle'.$i.'|numeric|greater_than_field:valorPagadoPagoForwardDetalle'.$i;   
  }
  return $validacion;
}


I do not know what error I may have but the code but this validation is not working.

    
asked by Santiago Muñoz 25.10.2016 в 15:53
source

1 answer

0

In your view, try to generate a

<input type="hidden" name="id[$id]" 

of the array type.

Then in your controller try to get it also as an array:

$array = $request->get('id');

Then process it in a loop:

foreach ($array as $key => $value) {

Update:

It is not hidden. You must have the name and the type of your field valueFacturaPagoForwardDetalle

    
answered by 25.10.2016 в 17:03