lundi 30 septembre 2019

Image in a header componer in Laravel

I have a header component that I render with @include('components.header') and in this header I have a user image that I should fetch from the database. To save the user image in the database I created a helper table called user_images where I save the user id, the base64 image and the status. The logic leaves only the image that the user is using as status 1 and the others with status 0 (zero). I need to fetch this logged in user image and display it in the header, but I don't know which controller to use the search. I want to fetch the image and make it available as soon as I log in

$user = Auth::user();
    $localization = UserLocalization::find($user->id);
    if(!$localization){
        $localization = new UserLocalization;
    }
    $images = UserImage::where('user_id', $user->id)->get();
    $image = UserImage::where('status', 1)->where('user_id', $user->id)->first();
    // dd($image);
    return view('admin.profile.index')->with(\compact('user'))
                                        ->with(\compact('localization'))
                                        ->with(\compact('images'))
                                        ->with(\compact('image'));

This way the image is only available on the controller in question. I would like it to be available throughout the application after login.

Someone to help me do this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire