Question

I'm fairly new to Laravel,so any help and pointers would be appreciated. I have already created a login and registration procedure. But i have trouble creating routes.My objective is that when a user successfully logs in, i wish to include the username as a url parameter and then output a profile page based on that username.

problem 1: example: $UserName = 'seLinux';

  • the user name will be placed to the url; www.mydomain.com/seLinux

a route will then handle this to output a profile page. The route i created is this. but i want to pass it on to a controller instead of creating the method inside the route.

Route::get('www.domain.com/{user_name}', function($user_name) {

// problem 2 how do i pass the $user_name to a controller accessing the profile method and not create a loop.

});

any help will be greatly appreciated. Thank you.

Was it helpful?

Solution

Something like this in your route:

 Route::get('profile/{user_name}', array(
        'uses' => 'UsersController@action'
 ));

In the UsersController:

public function action($user_name)
{
    //controller functions here
}

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top