How to use eloquent in a validation rule

Posted 2 years ago by Eco012390
$this->validate(request(), [
            'usn' => 'required|max:11|min:11',
            'name' => "required|min:3|max:32|regex:/^[\\p{L} .'-]+$/",
            'email' => 'required|email|unique:users,email',
            'password' => 'required|confirmed|min:6',
            'key' => Key::where('usn', request('usn'))
             ->where('activation_key', request('key'))
             ->where('used', 0)->first(); // Doesn't work but this is what I want to happen.
         ]);

Please sign in or create an account to participate in this conversation.