php - Laravel 4: Add username to every route url -
php - Laravel 4: Add username to every route url -
how add together username url?
example: www.domain.com/feeds/username
i want add together username every route url.
::route::
route::get('feeds', array('before' => 'auth', 'as' => 'feeds', 'uses' => 'feedscontroller@getfeedspage'));
::controller::
class feedscontroller extends basecontroller { public function getfeedspage() { homecoming view::make('feeds.index'); } }
thanks in advance.
michael.
you may seek this, declare route (notice {username}
):
route::get('feeds/{username}', array('before' => 'auth', 'as' => 'feeds', 'uses' => 'feedscontroller@getfeedspage'));
declare class
:
class feedscontroller extends basecontroller { // utilize parameter receive username public function getfeedspage($username) { // may access username passed via route // within method using $username variable homecoming view::make('feeds.index')->with('username', $username); } }
now may utilize uri
these:
www.domain.com/feeds/username1 www.domain.com/feeds/michaelsangma
php laravel laravel-routing
Comments
Post a Comment