0

I got these routes:

    Route::get('prefix/list/{page?}/{size?}', ['as' => 'prefix.list', 'uses' => 'MyController@getList']);
    Route::post('prefix/list', ['as' => 'prefix.list', 'uses' => 'MyController@postList']);

When I call link_to_route() like so:

{{ link_to_route('prefix.list', $page, ['page' => $page, 'size' => $size]) }}

It creates this link:

http://my.site/prefix/list?page=5&size=12

But when I remove the post route, it renders correctly this:

http://my.site/prefix/list/5/12

I don't want to change the name of the routes because my system depends on them being the same. How can I solve this?

Matheus Simon
  • 668
  • 11
  • 34
  • 1
    You could try just changing the order of the routes in your routes file, so that the get one comes last and overrides the post for the purposes of link_to_route(). Not 100 % sure it'll work, though. – Joel Hinz Nov 19 '16 at 18:44
  • @JoelHinz It worked! Post an answer and I'll mark it. Thanks! – Matheus Simon Nov 19 '16 at 18:46

1 Answers1

1

You could try just changing the order of the routes in your routes file, so that the get one comes last and overrides the post for the purposes of link_to_route().

Joel Hinz
  • 24,719
  • 6
  • 62
  • 75