class = $class; $this->relation = $relation; } /** * Run the validation rule. */ public function validate(string $attribute, mixed $value, Closure $fail): void { $relation = $this->relation; if ($this->class::find($value)->$relation()->exists()) { $fail("Relation {$this->relation} exists."); } } }