felixkiss / uniquewith-validator

Custom Laravel Validator for combined unique indexes
MIT License
389 stars 129 forks source link

Validation fails when updating composite keys with ignore #105

Closed ultrasamad closed 5 years ago

ultrasamad commented 5 years ago

I have this validation rule in my form request for model update

[
         ...
         'student_id'    => [
             'filled',
             'exists:students,id',
             "unique_with:results, subject_id, period_id,$this->id"
         ],
       ...
 ];

but then the validation keeps failing when updating a record.

ultrasamad commented 5 years ago

Sorry, I realized I wasn't fetching the id the proper way. Should be $this->result->id