0

I'm using the following code to generate a link:

{{ URL::route('monthly',array($year,$month_number)) }}

Which looks like

/monthly?1999&5

But what I really need is:

/monthly/1999/5

How should I accomplish this?

2
  • 1
    what does your route look like? it should look like Route::get('monthly/{year}/{month} ... Commented Sep 24, 2014 at 19:36
  • 1
    This should be handled automatically for you if you have a route that exists that matches Route::get('monthly/{year}/{month_number}') as the 2nd argument params should be applied into the constructor. Something else is going on here. Commented Sep 24, 2014 at 19:38

1 Answer 1

2

You have to create a route to support those parameters:

Route::get('montly/{year}/{month_number}', 'ControllerName@show');

And your controller method:

public function show($year, $month_number)
{
    ...
}
Sign up to request clarification or add additional context in comments.

1 Comment

Wow that did it! I wasn't thinking this would be an automatic thing.... bad assumption in Laravel. This is so convenient. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.