5.8 has different AuthenticateUsers system. For those who were getting errors can try this one : protected function sendFailedLoginResponse(Request $request) { $fields = $this->credentials($request); if ($fields['email'] == 'inactive'){ throw ValidationException::withMessages([ $errors = $request = $fields['password'], ]); } else{ throw ValidationException::withMessages([ $this->username() => [trans('auth.failed')], ]); } }
Thanks man this concept works :) I have using Laravel 5.8 code below for AuthenticatesUsers: protected function sendFailedLoginResponse(Request $request) { $fields =$this->credentials($request); if ($fields['email'] == 'inactive'){ throw ValidationException::withMessages([$errors = $fields['password'], ]); }else{ throw ValidationException::withMessages([$errors = [$this->username() => trans('auth.failed')], ]); } }
Interesting method :) A little confusing. I hope to see method: restrict user by IP address. Also.. Who gets error: "Type error: Argument 1 passed to App\Http\Controllers\Auth\LoginController::credentials() must be an instance of Illuminate\Support\Facades\Request, instance of Illuminate\Http\Request given" Just add inside LoginController.php: use Illuminate\Http\Request;
Hi sir, can I ask about the post edit.blade.php , how can i view the the file name of the image ? It is not showing the file name. How can I explode the path into file only into the input field? Thank you.
hi any one can help me in this lecture i cant understand my where we make message.php file ans whhat type of cose is written in message.php file.i cant show any credential error in admin login page when i write wrong email or password
Hi Ankur, I landed here thanks to your other video on Status login. And this is throwing me an error. I believe that I have to create a Model to use ::where(...) ? Please can you help on that one ?
it's fine, I imported User model and used it. But I still have an issue as in Laravel 5.6, AuthenticatesUsers.php is not the same than 5.5. So even if I put: $fields = $this->credentials($request); if ($fields['email'] == 'inactive') { $errors = $fields['password']; } else { throw ValidationException::withMessages([ $this->username() => [trans('auth.failed')], ]); } It still doesn't work :/
Try without count() protected function credentials(Request $request) { $admin = admin::where('email',$request->email)->first(); if ($admin) { if ($admin->status == 0) { return ['email'=>'inactive','password'=>'You are not an active person, please contact Admin']; }else{ return ['email'=>$request->email,'password'=>$request->password,'status'=>1]; } } return $request->only($this->username(), 'password'); }
protected function credentials(Request $request) { $admin = admin::where('email',$request->email)->first(); if (count($admin)) { if ($admin->status == 0) { return ['email'=>'inactive','password'=>'You are not an active person, please contact Admin']; }else{ return ['email'=>$request->email,'password'=>$request->password,'status'=>1]; } } return $request->only($this->username(), 'password'); } I have written this code within file app/Http/Controllers/Admin/Auth/LoginController.php
5.8 has different AuthenticateUsers system. For those who were getting errors can try this one :
protected function sendFailedLoginResponse(Request $request)
{
$fields = $this->credentials($request);
if ($fields['email'] == 'inactive'){
throw ValidationException::withMessages([
$errors = $request = $fields['password'],
]);
} else{
throw ValidationException::withMessages([
$this->username() => [trans('auth.failed')],
]);
}
}
Thanks man this concept works :)
I have using Laravel 5.8 code below for AuthenticatesUsers:
protected function sendFailedLoginResponse(Request $request)
{
$fields =$this->credentials($request);
if ($fields['email'] == 'inactive'){
throw ValidationException::withMessages([$errors = $fields['password'],
]);
}else{
throw ValidationException::withMessages([$errors = [$this->username() => trans('auth.failed')],
]);
}
}
thanks again...and one more request - pls upload the next parts as soon as possible.
Yup sure, thanks for watching Please like Bitfumes on facebook to get latest updates.
Thanks again for your videos. They are really cool)))
Interesting method :) A little confusing.
I hope to see method: restrict user by IP address.
Also..
Who gets error:
"Type error: Argument 1 passed to App\Http\Controllers\Auth\LoginController::credentials() must be an instance of Illuminate\Support\Facades\Request, instance of Illuminate\Http\Request given"
Just add inside LoginController.php:
use Illuminate\Http\Request;
Thanks pastuh for helping others. Keep learning.
Hi sir, can I ask about the post edit.blade.php , how can i view the the file name of the image ? It is not showing the file name. How can I explode the path into file only into the input field? Thank you.
i has some difficulties in this part with laravel 5.7 .anyone can help?
Nice tutorial
Thanks for watching bro
hi any one can help me in this lecture i cant understand my where we make message.php file ans whhat type of cose is written in message.php file.i cant show any credential error in admin login page when i write wrong email or password
Nice brother
Thanks for watching bro
How to do in 5.7 because it is different code 7:40
hello how to do it in laravel 7
Hey Dear, How to deploy laravel vuejs application with nginx
Okay, I have to see that, then I will create video about that also
Hi Ankur, I landed here thanks to your other video on Status login. And this is throwing me an error. I believe that I have to create a Model to use ::where(...) ? Please can you help on that one ?
it's fine, I imported User model and used it. But I still have an issue as in Laravel 5.6, AuthenticatesUsers.php is not the same than 5.5. So even if I put:
$fields = $this->credentials($request);
if ($fields['email'] == 'inactive') {
$errors = $fields['password'];
} else {
throw ValidationException::withMessages([
$this->username() => [trans('auth.failed')],
]);
}
It still doesn't work :/
It's fine with some logic, I got it working :) Thanks alot
Hello how u fixed it please tell us
how you solve this hope you reply this...Youssef Amakrane
To fix the problem write this
$admin = admin::where('email',$request->email)->first();
if ($admin === null)
{
return $request->only($this->username(), 'password');
}elseif ($admin->status == 0)
{
return ['email'=>'inactive','password'=>'You are not an active person, please contact Admin'];
}else
{
return ['email'=>$request->email,'password'=>$request->password,'status'=>1];
}
i use COUNT() in laravel 5.7 it not work
Try without count()
protected function credentials(Request $request)
{
$admin = admin::where('email',$request->email)->first();
if ($admin) {
if ($admin->status == 0) {
return ['email'=>'inactive','password'=>'You are not an active person, please contact Admin'];
}else{
return ['email'=>$request->email,'password'=>$request->password,'status'=>1];
}
}
return $request->only($this->username(), 'password');
}
@@yusuf-fauzan it worked,
sorry, that was my silly mistake .... Thank you :)
Hi Bro, i got this error
count(): Parameter must be an array or an object that implements Countable
How to solve this please suggest me.
what you have written?
protected function credentials(Request $request)
{
$admin = admin::where('email',$request->email)->first();
if (count($admin)) {
if ($admin->status == 0) {
return ['email'=>'inactive','password'=>'You are not an active person, please contact Admin'];
}else{
return ['email'=>$request->email,'password'=>$request->password,'status'=>1];
}
}
return $request->only($this->username(), 'password');
}
I have written this code within file app/Http/Controllers/Admin/Auth/LoginController.php
hlo sir same here what is the solution of this ?
@@mandeepdhundwa i also have this error.
have you solved this error??
For Laravel 5.8
protected function sendFailedLoginResponse(Request $request)
{
/*throw ValidationException::withMessages([
$this->username() => [trans('auth.failed')],
]);*/
$fields =$this->credentials($request);
if ($fields['email'] == 'inactive'){
throw ValidationException::withMessages([$errors = $fields['password'],
]);
}else{
throw ValidationException::withMessages([$errors = [$this->username() => trans('auth.failed')],
]);
}
}