Custom Validation with relation

->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");
      }
    };
}]),


I need to replace replaceWithRelationID with the parameter ID from the url or the relationship its on.
Was this page helpful?