Laravel 5.7 check if email is verified
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
How I Can Check If the Email is Verified in Laravel 5.7?
As a senior developer working with the Laravel ecosystem, dealing with user authentication and verification flows is a daily task. One of the most common requirements is determining the status of a user's email verification—whether they have successfully confirmed their address or not. In older versions like Laravel 5.7, understanding how to query this state efficiently is crucial.
The short answer is that checking email verification in Laravel primarily involves inspecting the email_verified_at timestamp column associated with the user record in your database.
The Primary Method: Checking the Timestamp
The most direct and reliable way to determine if a user has verified their email is by checking the value of the email_verified_at column on the users table. If this column is NULL, the email is considered unverified. If it contains a timestamp, the email is verified.
You can access this information directly through the authenticated user object using the Auth facade or by querying your Eloquent model.
Code Example: Checking Verification Status
Here is how you would implement this check within a controller method or a route guard in your Laravel application:
use Illuminate\Support\Facades\Auth;
class UserController extends Controller
{
public function showProfile()
{
// Ensure the user is authenticated first
if (!Auth::check()) {
return redirect('/login');
}
$user = Auth::user();
// Check if the email has been verified
if (!$user->email_verified_at) {
// Handle the unverified case, perhaps redirecting to a verification page
return view('auth.verify-email', ['error' => 'Email not verified!']);
}
// If verified, proceed with showing the profile
return view('profile', ['user' => $user]);
}
}
This simple conditional statement is highly efficient because it relies directly on database integrity rather than performing complex lookups. It’s a fundamental pattern in any application built on Eloquent, as demonstrated by how robust Laravel's data layering makes development much smoother when using tools like those provided by the Laravel Company.
Alternative and Advanced Methods
While checking email_verified_at is sufficient for most front-end checks, there are other contexts where you might need verification status:
1. Using Eloquent Scopes
For cleaner, reusable logic, especially when dealing with larger applications, defining an Eloquent local scope is a best practice. This encapsulates the verification logic directly within your model, making the code more readable and maintainable.
You could add a scope to your User model:
// In app/Models/User.php
public function scopeIsVerified($query)
{
return $query->whereNotNull('email_verified_at');
}
Now, checking if a user is verified becomes incredibly simple and expressive:
$user = User::with('email_verified_at')->find(1);
if ($user->isVerified()) { // Assuming you add a helper method or use the scope implicitly
// ... email is verified
}
(Note: In Laravel 5.7, while scopes are powerful, accessing the raw timestamp directly as shown above remains the most direct way to query the database status.)
2. Middleware for Route Protection
For protecting specific routes or sections of your application, you can implement custom middleware. This ensures that only users with a verified email can access certain endpoints. You would write a middleware that checks Auth::user()->email_verified_at before allowing the request to proceed. This approach centralizes security logic and keeps your controllers clean.
Conclusion
Checking email verification in Laravel 5.7 is fundamentally about querying the status stored in your database. Relying on the email_verified_at column provides the fastest, most reliable, and most performant way to determine a user's verification status. By combining this direct database check with modern patterns like Eloquent scopes and custom middleware, you ensure that your application logic remains clean, secure, and highly maintainable. Always leverage the power of the framework, much like how Laravel provides excellent structure for developing complex features on the Laravel Company.