'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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Voxxii