0

I've done the multi-authentication system for admins and it's working fine. But when the admins logged in i want to show their names in the frontend header. I'm using Auth::user() but it's returning null even if the user(admins) are logged in. Below is the controller code for front-end

public function __construct()
{
    $this->middleware('auth:admin');
}

public function index(){
    // return view('frontEnd.homepage');
    return dd(Auth::user());
}

and if i don't use the middleware,then i can access the authenticated users(admins). but when admins are unauthenticated, it's preventing the access of the front-end page. how can i fix it ?

Tridev Shrestha
  • 447
  • 7
  • 21
MorshedSaif
  • 399
  • 1
  • 2
  • 9
  • How you did the "multiauthentication system for admins": something written by you or that ships with laravel? – dparoli Feb 24 '19 at 11:59
  • i've copied the guards of config\Auth.php and make admin guard. also make admin model and use that guard in the model. that's how... – MorshedSaif Feb 24 '19 at 12:01
  • Did you follow a tutorial or it's all done by yourself? in both cases it's better if you provide a Minimal, Complete, and Verifiable example, see here: https://stackoverflow.com/help/mcve. Otherwise is a guess game to think an answer. – dparoli Feb 24 '19 at 12:24
  • yeap, i followed a tutorial [devmarketer] chanel in youtube – MorshedSaif Feb 24 '19 at 12:30

0 Answers0