Level 39
You should be able to create your own rule "UniqCodePerYear"
use this doc
https://laravel.com/docs/9.x/validation#using-rule-objects
to define the rule and access all the data
and your validation can be st like this
$count = DB::table('my_table')->where('code', $value)
->where('year', $data->year)
->count();
return $count === 0;
or you change your db use a field code_year.
1 like