I'm creating a Laravel web site where users can login and upload images. For visitors to see that user's gallery, I've set up a gallery page with a URL like https://localhost8000/gallery/2, where 2 is the user ID.
My current code looks like this.
web.php
Route::get('/menu/{user}', 'CartController@menu');
CartController.php
public function menu($user)
{
$user = User::findOrFail($user);
return view('new_menu')->with(['user' => $user]);
}
Instead of using the user ID as a route parameter, I want to use a random string. Currently a random string of 32 digits is created when the user registers and stored in the users
table in a column called random
.
I couldn't figure out how to relate "random" to "user" in web.php and Controller.
source https://stackoverflow.com/questions/70128106/laravel-how-to-use-a-parameter-other-than-user-id-in-a-url
Comments
Post a Comment