Skip to content

Instantly share code, notes, and snippets.

@lawjeremy
Last active December 21, 2015 14:48
Show Gist options
  • Save lawjeremy/c6e05253e9a73d2f6e23 to your computer and use it in GitHub Desktop.
Save lawjeremy/c6e05253e9a73d2f6e23 to your computer and use it in GitHub Desktop.
Laravel validator extension for unique email today. Usage: unique_today:table_name
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