https://laravel.com/docs/5.4/helpers#method-session
https://laravel.com/docs/5.4/validation#rule-in
Edit: Welcome to the board! I have such a terrible StackOverflow habit of just pasting links in comment boxes lol, I need to pack it in on here!
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone,
my name is Julia and I'm new in this board and also new to Laravel but until now I love it :)
But at the moment I got a problem which google cant answer me. I have a array with some user specific ids. As an example a user has ids 3,4,5 and 6. They come from a database.
Than they are stored in an accessibale array. With this array I build navigation menu in main.blade.php.
So every user is able to see a some pages with some data. These data comes also from a database. This user should be able to show only the data from id 3,4,5 and 6. So I want to store the actual id in a session variable.
And the user should be able to change this session id with a link in the navigation menu. BUT he also should be able to change it to 3,4,5 or 6. So not to 7 because this would be an other users data.
So how can i savely change the session variable by an link in the menu? Afterwards I could also check if the new variable which should be stored in the session varaible is element of users id (in this case 3 to 6).
Thanks for any advice :)
Literally any way you like
Route::get('/change-number', [ 'as' => 'change-number',
'uses' => 'ChangeNumberController@update'
]);
{!! route('change-number') !!}
You could do it with wildcards which would also be an option, but this method is the most basic
Please or to participate in this conversation.