samedi 15 août 2020

Cannot validate array in Laravel

I have an array which i'm getting through request:

$rules=[];
$Fields=[];
foreach($request->input('users') as $user) {
  $Fields+=$user['name'];
  array_push($rules, [$user['name'] => 'required']);
}

Now i'm trying to validate it as follows:

$validate = Validator::make($Fields,$rules);
  if($validate->fails()){
    echo "Fails";
  } else {
    echo "Pass";
  }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire