1

I used https://github.com/Kbwebs/MultiAuth and make all steps
i make Register but in login when i entered, it's entered with the first one in array if it admin, Admin only logged in and customer don't Auth.php

'multi-auth' => [
    'admin' => [
        'driver' => 'eloquent',
        'model'  => App\AdminModel::class
    ],
    'customer' => [
        'driver' => 'eloquent',
        'model'  => App\CustomerModel::class
    ]
],

postLogin()

   public function postLogin(Request $request)
    {
        $this->validate($request, [
            $this->loginUsername() => 'required', 'password' => 'required',
        ]);

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.

        $throttles = $this->isUsingThrottlesLoginsTrait();

        if ($throttles && $this->hasTooManyLoginAttempts($request)) {
            return $this->sendLockoutResponse($request);
        }

        $credentials = $this->getCredentials($request);


        if (Auth::admin()->attempt($credentials, $request->has('remember'))) {
           return redirect('Admin');
        }

        if (Auth::customer()->attempt($credentials, $request->has('remember'))) {
           return redirect('/');
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.

        if ($throttles) {
            $this->incrementLoginAttempts($request);
        }

        return redirect($this->loginPath())
            ->withInput($request->only($this->loginUsername(), 'remember'))
            ->withErrors([
                $this->loginUsername() => $this->getFailedLoginMessage(),
            ]);
    }
Kassim
  • 11
  • 1
  • what are you trying to ask here? – prasun Oct 09 '15 at 14:51
  • When i login it login with the first table Admin but not login with customer,when i login with customer it redirect to login page – Kassim Oct 09 '15 at 14:58
  • Follow these steps as laravel 5.2 gives multi auth out of the box .. http://stackoverflow.com/questions/34614753/can-anyone-explain-laravel-5-2-multi-auth-with-example/34783443#34783443 – imrealashu Feb 11 '16 at 17:12

0 Answers0