Reputation: 8085
I might be misunderstanding the link to route helper, but its not working without a route set up in my routes file.
{{ link_to_action('UserController@loginWithFacebook', 'Facebook Login in', $parameters = array(), $attributes = array('class' => 'btn btn-primary fb-login-btn')); }}
Then an old route when I was linking to a URI was:
Route::get('loginuser2', array('uses' => 'UserController@loginWithFacebook'));
However, I thought link_to_action was a direct call to the method. After removing the above link in my routes file I get not defined route errors for the controller method.
Any ideas how to avoid this?
Upvotes: 1
Views: 1764
Reputation: 614
link_to_action is used to link to a controller. you should use
link_to to generate html link
echo link_to('foo/bar', $title, $attributes = array(), $secure = null);
Upvotes: -1
Reputation: 60048
You cant link to an action if the route itself does not exist. The route must be defined.
So you need to keep the route defined, and then link_to_action()
will continue to work. On the backend it is looking at your routes to find the same route with that action - and uses that URL.
There is no way to avoid it.
Upvotes: 4