samedi 29 février 2020

Use Auth in AppServiceProvider

I need the ID of the user who is logged in to get a photo in the profile table, here I am trying to use View but only in the index function that gets $ profile, I want all files in the view to have $ profile

 public function index()
 {
  $profil = Profil_user::where('user_id',$auth)->first();
  View::share('profil', $profil);
  return view('user.index');
}

I have also tried AppServiceProvider but I get an error in the form of a null value if I don't log in, is there a solution to my problem?

 public function boot()
{
    $auth = Auth::user();
    dd($auth);
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire