how to add multiple conditions in unique property laravel?

  laravel, php, validation

Table : charges

id | ac_id | year |
| - | -- |-------------- |
| 1 | 1  | 2021          |
| 2 | 1  | 2020          |
| 3 | 2  | 2021          |
| 4 | 2  | 2020          |

I am having a problem while doing validation, the year should be unique with respect to the ac_id

 'year'=>"required|unique:charges,year",

This validation rule I tried but not working while adding the same year for different ac_id

Source: Ask PHP

LEAVE A COMMENT