How to Check if an Email Already Exists in the Database in Laravel
In this lesson, we will see how to check if an email already exists in the database in Laravel, there are many ways you can do that but in this lesson, we will use the Rule's exists method.
Check if email already exists
To do that check the code below:
use App\Models\User;
use Illuminate\Validation\Rule;
public function auth(Request $request)
{
$request->validate([
'email' => ['required', 'email', Rule::exists(User::class, 'email')]
]);
}