سؤال

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 ?

هل كانت مفيدة؟

المحلول

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

}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top