Pergunta

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 ?

Foi útil?

Solução

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";
    }

}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top