first_name = $firstName; $this->last_name = $lastName; $this->school_id = $schoolID; } public function studentExists(): bool { return Student::where('first_name', $this->first_name) ->where('last_name', $this->last_name) ->where('school_id', $this->school_id) ->exists(); } public function message(): string { return 'There is already a student with that name at the school you are trying to add them to'; } /** * Run the validation rule. * * @param Closure(string): PotentiallyTranslatedString $fail */ public function validate(string $attribute, mixed $value, Closure $fail): void { if ($this->studentExists()) { $fail($this->message()); } } }