vendredi 24 février 2017

Laravel / Vue: Validating when using v-model

I am using Laravel and Vue js, and I can not figure out how to validate this field using Laravel.

Vue-component:

<div v-for="problem in problemsprop">
     <div>
          <label :for="problem.id"></label>
          <input type="text" class="form-control" :id="problem.id" 
                 v-model="problem.rating">
     </div>
</div>

This returns an array

array:2 [
 "problems" => array:2 [
    0 => array:2 [
      "id" => 33
      "rating" => "12"
  ]
    1 => array:2 [
      "id" => 38
      "rating" => "3"
  ] 
]
]

Now I do not know how to validate this using Laravels validation. I have tried a lot of things like

    $this->validate($request, [
        'rating' => 'required|integer',
    ]);

But this does of course not work here. Can anyone please help me?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mkdyHa
via IFTTT

Aucun commentaire:

Enregistrer un commentaire