Laravel 7 login error message not showing
Created at 07-Aug-2021 ,
By samar
Laravel 7 login error message not showing
Hello everyone, in this post we will examine how to solve the "Laravel 7 login error message not showing" programming puzzle.
Laravel 7 login error message not showing in blade file. You can display validation or custom error messages by using the @error directive in laravel. To display the custom error message you have to return back with the custom message using withErrors() method.-
Display validation error messages for login functionality in laravel
--PATH resources\views\auth\login.blade.php// For email required and invalid login credentials @error('email') <span class="invalid-feedback" role="alert"> <strong>{{ $message }}</strong> </span> @enderror //For password required @error('password') <span class="invalid-feedback" role="alert"> <strong>{{ $message }}</strong> </span> @enderror
-
Return with custom error message other than validation in laravel on login
--PATH app\Http\Controllers\Auth\LoginController.php//Return with validation error message if input is empty $credentials = $request->validate([ 'email' => ['required', 'email'], 'password' => ['required'], ]); //It will redirect to dashboard if everything is ok if (Auth::attempt($credentials)) { $request->session()->regenerate(); return redirect()->intended('dashboard'); } //Return back to login page with custom error message return back()->withErrors([ 'email' => 'The provided credentials do not match our records.', ]);
Related Queries
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Create project table with model and migration
- Trying to get property 'title' of non-object
- Database transactions in laravel
- Call to undefined relationship [user] on model [App\Models\Post]
- Get the post details if it has at least one comment in comments table
- How to validate URL with https using regex in laravel
- Call to a member function getRelationExistenceQuery() on array in Laravel
- How to check data inserted or deleted in pivot after toggle method
- How to change default timestamp fields name in Laravel
- Validation for multiple forms on same page in laravel
- How to display pivot table column value in laravel
- Credit card validation in laravel
- On delete set foreign id column value null using migration in laravel 8
- How to access the nth object from Laravel collection object ?
- Delete all related comments on deleting a post in Laravel
- How to check email is valid or not in Laravel
- Route not defined in Laravel
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- Laravel order by date not working
- Split an Eloquent Collection by half in Laravel
- Route prefix with auth middleware in laravel
- There are no commands defined in the "route:" namespace
- How to display order by null last in laravel
- Input file with max size validation in laravel
- Print query in laravel