Question

I'm new to Laravel and i'm working on social application and i want the generated routes be something like this :

-www.app.com/username

-www.app.com/username/boards

-www.app.com/username/boards/ID 

-www.app.com/username/follower .. etc 

Any help with that ?

Was it helpful?

Solution

You can do things like this with Laravel's router:

Route::get('{username}/boards', 'BoardsController@show')
   ->where('username', '[A-Za-z]+');

And then you just need a controller:

class BoardsController extends Controller {

    public function show($username)
    {
        return "showing boards for $username";
    }

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