In this Validator
of Laravel
, what is the right code with variable?
public function salvar()
{
$n =Request::input('campos');
for($i=1; $i < $n; $i++){
$pontosa =Request::input('pontosa'.$i);
$pontosb =Request::input('pontosb'.$i);
$validator = Validator::make(
[ "'pontosa'.$i" => $pontosa,
"'pontosb'.$i" => $pontosb
],
[
'pontosa.$i' => 'required|numeric',
'pontosb.$i' => 'required|numeric'
]);
if($validator->fails())
{
return redirect()
->action('UsersController@lista');