Skip to content

Instantly share code, notes, and snippets.

@mikehins
Created May 22, 2024 02:20
Show Gist options
  • Save mikehins/6ece231ade0ffe54a7988d461a753650 to your computer and use it in GitHub Desktop.
Save mikehins/6ece231ade0ffe54a7988d461a753650 to your computer and use it in GitHub Desktop.
Schema::table('users', function (Blueprint $table) {
$table->string('email_sanitized')->virtualAs('
CONCAT(
SUBSTRING_INDEX(email, "@", 1),
"@",
SUBSTRING_INDEX(email, "@", -1)
)
')->unique();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment