0
votes

I am attempting to declare a method/function in my controller that responds to a numerically named route. When I load any page in the site I receive an error stating the controller method could not be found, meaning that Laravel won't even load the application do to some incorrect formatting. I searched for an answer with no luck.

Here is the route I'm attempting to access via my Math controller:

students/academics/math/7-12

Here is the method declaration to look for the route:

public function get712()

Which gives me the following error no matter what page I'm loading:

Call to undefined method Illuminate\Routing\Router::get712()

I'm not sure how to name the function/method in my controller for a purely numeric routes since hyphen is not allowed and there is no upper/lowercase for numbers.

2

2 Answers

3
votes

why not pass 7-12 as a variable to a method?

route:

students/academics/math/{number} 

controller:

public function getMath($number)
{
    // code here
}
1
votes

I remembered that Laravel used to use underscores in the method name instead of camelCase so after scouring Google with no luck I declared the method like this:

public function get_7_12()

voila!