Last active
December 21, 2015 14:48
-
-
Save lawjeremy/c6e05253e9a73d2f6e23 to your computer and use it in GitHub Desktop.
Laravel validator extension for unique email today. Usage: unique_today:table_name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validator::extend ( 'unique_today', function ( $attribute, $value, $parameters ) { | |
$var[0] = $value; | |
$results = DB::select('SELECT * FROM ' . $parameters[0] . ' WHERE email = ? AND DATE(created_at) = DATE(NOW());', $var); | |
if ( $results ) { | |
return false; | |
} | |
return true; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment