Laravel Check Duplicate Records


Laravel Check Duplicate Records: We often need to check duplicate records when working with database table records. It is very simple to check the duplicate records in Laravel. Here in this tutorial we are going to explain how you can Check duplicate Records in Laravel.


Laravel Check Duplicate Records Example | Laravel check if user exists

Here we have checked that the given email exists in the database table or not. You can simply check the duplicate records in Laravel simply as below-

Laravel Check Duplicate Records Query Example:

<?php
$email = "john@example.com";
$userExists = Users::where('email', '=', $email)->first();
if ($userExists === null) {
   // User Not Found Your Stuffs Goes Here..
}
?>

The above example will check the given email exists in the database table or not it does not exists then it will return null, Using this response you do other stuffs.


Advertisements

Add Comment

📖 Read More