Showing posts with label action. Show all posts
Showing posts with label action. Show all posts

Sunday, June 25, 2017

Laravel 5: Generate a URL to a controller action

It's easy to generate a URL as like Controller Action. Suppose you have a controller named "UserController" and have an action inside the Controller named "customerLogin" and in routes.php you mentioned the router as: 

"Route::get("login_customer", "UserController@customerLogin"

So when you browse www.domain.com/login_customer then actually executed "customerLogin" action of "UserController".

Now for some reason you need to construct a URL based on Controller and Action, then you can apply below to generate URL:

action('UserController@customerLogin', ['id' => "3 0"])

Will generate below URL:

www.domain.com/login_customer?id=3+0

If you Controller exists inside another folder then you ca

action('Folder\UserController@customerLogin', ['id' => "3 0"])


Monday, April 22, 2013