Custom Validation with relation
I need to replace
replaceWithRelationID with the parameter ID from the url or the relationship its on.replaceWithRelationID->rules([function ($record) {
return function (string $attribute, $value, Closure $fail) use ($record) {
if (Model::where('agreement_id', $replaceWithRelationID)->whereDate('start_date', '>=', $value)->exists()) {
$fail("There is already a price agreement right/after this date");
}
};
}]),