Reputation: 4419
I'm having some problems with laravel 4 route reversing. Basically I have a restful controller that needs reversing. There's very little information on the internet about how to do it, and the existing ones all talk about laravel 3(and very vague). I checked them out, they propose "Case 1" in the following code, which didn't work. After a lot guessing and struggling I found out "Case 2" works. Why is Case 1 not working? How should I get it to work?
FooController.php
class FooController extends BaseController{
public function getHello(){
return View::make("bar");
}
}
routes.php
Route::controller("foo","FooController ");
bar.blade.php
{{URL::action('foo@hello')}}//Case 1: This doesn't work
{{URL::action('FooController@getHello')}}//Case 2: This works
Upvotes: 0
Views: 2273
Reputation: 22872
These lead to same controller/action after all...
// routes.php
Route::get('foo/hello', 'as' => 'foo.hello', 'uses' => 'FooController@getHello');
// Somewhere in your view, etc.
{{ URL::to('foo/hello') }}
{{ URL::action('FooController@getHello') }}
{{ URL::route('foo.hello') }}
Upvotes: 3