Skip to content
Advertisement

Where to store user profile id for multiple user profile in laravel [closed]

In my laravel project, I have 2 tables as users and profiles. One user can have multiple profile. The user is logged into their account using user table. Now the profiles are listed as a drop-down menu. Once a user switch a profile by selecting anyone from the drop-down, what’s the good practice to store the user profile id?

I’m planning to store the user’s choice in the session.

Advertisement

Answer

You can save the profiles in session array.

$profiles = array('prof1','prof2','prof3', ...);
Session::put('userProfiles', $profiles);

To show your session in a blade you can use a foreach:

@foreach (Session::get('userProfiles') as $profile)
    {{$profile}}
@endforeach

Note: this was one mode, for sure you can use other for same thing.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement