Laravel - Create Blog and Admin Panel | Login with status and error message #31

Поділитися
Вставка
  • Опубліковано 19 вер 2024

КОМЕНТАРІ • 37

  • @khabirulbasartonmoy2057
    @khabirulbasartonmoy2057 5 років тому +2

    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')],
    ]);
    }
    }

    • @neerajsinghtangariya2587
      @neerajsinghtangariya2587 5 років тому +3

      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')],
      ]);
      }
      }

  • @mosharofhossain4583
    @mosharofhossain4583 7 років тому

    thanks again...and one more request - pls upload the next parts as soon as possible.

    • @Bitfumes
      @Bitfumes  7 років тому

      Yup sure, thanks for watching Please like Bitfumes on facebook to get latest updates.

  • @giorgi18806
    @giorgi18806 3 роки тому

    Thanks again for your videos. They are really cool)))

  • @pastuh
    @pastuh 7 років тому +1

    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;

    • @Bitfumes
      @Bitfumes  7 років тому +1

      Thanks pastuh for helping others. Keep learning.

  • @bernardbelda.8694
    @bernardbelda.8694 5 років тому +1

    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.

    • @kyawzin1722
      @kyawzin1722 5 років тому

      i has some difficulties in this part with laravel 5.7 .anyone can help?

  • @bernardchisumo4054
    @bernardchisumo4054 7 років тому

    Nice tutorial

    • @Bitfumes
      @Bitfumes  7 років тому

      Thanks for watching bro

  • @shoaibmaqsood5304
    @shoaibmaqsood5304 5 років тому

    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

  • @rayanasynat1954
    @rayanasynat1954 7 років тому

    Nice brother

    • @Bitfumes
      @Bitfumes  7 років тому

      Thanks for watching bro

  • @YasirMalik24
    @YasirMalik24 5 років тому

    How to do in 5.7 because it is different code 7:40

  • @filament02
    @filament02 4 роки тому

    hello how to do it in laravel 7

  • @AwadheshKumar-vb2us
    @AwadheshKumar-vb2us 7 років тому

    Hey Dear, How to deploy laravel vuejs application with nginx

    • @Bitfumes
      @Bitfumes  7 років тому

      Okay, I have to see that, then I will create video about that also

  • @youssef.freelife
    @youssef.freelife 6 років тому

    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 ?

    • @youssef.freelife
      @youssef.freelife 6 років тому

      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 :/

    • @youssef.freelife
      @youssef.freelife 6 років тому

      It's fine with some logic, I got it working :) Thanks alot

    • @shocktek8758
      @shocktek8758 6 років тому

      Hello how u fixed it please tell us

    • @isharadilshan8564
      @isharadilshan8564 6 років тому

      how you solve this hope you reply this...Youssef Amakrane

    • @nourali9498
      @nourali9498 5 років тому

      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];
      }

  • @vanchai1111
    @vanchai1111 5 років тому

    i use COUNT() in laravel 5.7 it not work

    • @yusuf-fauzan
      @yusuf-fauzan 5 років тому +3

      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');
      }

    • @gawate
      @gawate 4 роки тому

      ​@@yusuf-fauzan it worked,
      sorry, that was my silly mistake .... Thank you :)

  • @sohailAkhterktr
    @sohailAkhterktr 6 років тому

    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.

    • @Bitfumes
      @Bitfumes  6 років тому

      what you have written?

    • @sohailAkhterktr
      @sohailAkhterktr 6 років тому

      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

    • @mandeepdhundwa
      @mandeepdhundwa 6 років тому

      hlo sir same here what is the solution of this ?

    • @farazahmad7928
      @farazahmad7928 5 років тому

      @@mandeepdhundwa i also have this error.

    • @farazahmad7928
      @farazahmad7928 5 років тому

      have you solved this error??

  • @neerajsinghtangariya2587
    @neerajsinghtangariya2587 5 років тому

    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')],
    ]);
    }
    }