{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/7917","labels_url":"https://api.github.com/repos/laravel/framework/issues/7917/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/7917/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/7917/events","html_url":"https://github.com/laravel/framework/issues/7917","id":60220299,"number":7917,"title":"Route handled with get* instead of post*","user":{"login":"brazorf","id":3330031,"avatar_url":"https://avatars.githubusercontent.com/u/3330031?v=3","gravatar_id":"","url":"https://api.github.com/users/brazorf","html_url":"https://github.com/brazorf","followers_url":"https://api.github.com/users/brazorf/followers","following_url":"https://api.github.com/users/brazorf/following{/other_user}","gists_url":"https://api.github.com/users/brazorf/gists{/gist_id}","starred_url":"https://api.github.com/users/brazorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brazorf/subscriptions","organizations_url":"https://api.github.com/users/brazorf/orgs","repos_url":"https://api.github.com/users/brazorf/repos","events_url":"https://api.github.com/users/brazorf/events{/privacy}","received_events_url":"https://api.github.com/users/brazorf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-07T19:21:18Z","updated_at":"2015-03-08T16:24:38Z","closed_at":null,"body":"My route\r\n```php\r\nRoute::controller('my/route/{args?}', 'My\\Controller');\r\n```\r\n\r\nMy controller\r\n```php\r\nclass Controller extends Controller {\r\n    function getIndex($args = null) {\r\n      return \"get\";\r\n    }\r\n\r\n    function postIndex($args = null) {\r\n      return \"post\";\r\n    }\r\n}\r\n```\r\n\r\nGET \"my/route\" returns \"get\"\r\nGET \"my/route/1\" returns \"get\"\r\nPOST \"my/route/1\" returns \"post\"\r\nPOST \"my/route\" returns \"get\"\r\n\r\nAs you see there's a weird behaviour when there are no arguments to the post route. Is this by design?"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/77758957","html_url":"https://github.com/laravel/framework/issues/7917#issuecomment-77758957","issue_url":"https://api.github.com/repos/laravel/framework/issues/7917","id":77758957,"user":{"login":"brazorf","id":3330031,"avatar_url":"https://avatars.githubusercontent.com/u/3330031?v=3","gravatar_id":"","url":"https://api.github.com/users/brazorf","html_url":"https://github.com/brazorf","followers_url":"https://api.github.com/users/brazorf/followers","following_url":"https://api.github.com/users/brazorf/following{/other_user}","gists_url":"https://api.github.com/users/brazorf/gists{/gist_id}","starred_url":"https://api.github.com/users/brazorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brazorf/subscriptions","organizations_url":"https://api.github.com/users/brazorf/orgs","repos_url":"https://api.github.com/users/brazorf/repos","events_url":"https://api.github.com/users/brazorf/events{/privacy}","received_events_url":"https://api.github.com/users/brazorf/received_events","type":"User","site_admin":false},"created_at":"2015-03-08T16:24:38Z","updated_at":"2015-03-08T16:24:38Z","body":"I've ran some blackbox test, here's the result.\r\nEach test contains the route declaration, the Controller methods and 4 results.\r\n\r\n```php\r\n// No args\r\nRoute::controller('test', 'My\\Controller');\r\nfunction getIndex() { return \"index\"; }\r\nfunction getLocation() { return \"location\"; }\r\nResults:\r\nget 'test'\t\t\tok\r\nget 'test/1'\t\tok (not found)\r\nget 'test/location'\t\tok\r\nget 'test/location/1'\tok\r\n----------------------\r\n```\r\n\r\n```php\r\n// Mandatory arg\r\nRoute::controller('test/{args}', 'My\\Controller');\r\nfunction getIndex($arg) { return \"index\"; }\r\nfunction getLocation($arg) { return \"location\"; }\r\nResults:\r\nget 'test'\t\t\t\tok (not found)\r\nget 'test/1'\t\t\tok\r\nget 'test/location'\t\tok (not found)\r\nget 'test/location/1'\tERR (NotFoundHttpException)\r\n----------------------\r\n```\r\n\r\n```php\r\n// Mandatory arg - no args on controller methods\r\nRoute::controller('test/{args}', 'My\\Controller');\r\nfunction getIndex() { return \"index\"; }\r\nfunction getLocation() { return \"location\"; }\r\nResults:\r\nget 'test'\t\t\t\tok  (not found)\r\nget 'test/1'\t\t\t?   (returns \"index\" even though $arg is not declared)\r\nget 'test/location'\t\tERR (returns \"index\")\r\nget 'test/location/1'\tERR (NotFoundHttpException)\r\n----------------------\r\n```\r\n\r\n```php\r\n// Optional args\r\nRoute::controller('test/{args?}', 'My\\Controller');\r\nfunction getIndex($arg = null) { return \"index\"; }\r\nfunction getLocation($arg = null) { return \"location\"; }\r\nResults:\r\nget 'test'\t\t\t\tok\r\nget 'test/1'\t\t\tok\r\nget 'test/location'\t\tERR (returns \"index\")\r\nget 'test/location/1'\tERR (NotFoundHttpException)\r\n----------------------\r\n```\r\n\r\n```php\r\n// Optional args - no args on controller methods\r\nRoute::controller('test/{args?}', 'My\\Controller');\r\nfunction getIndex() { return \"index\"; }\r\nfunction getLocation() { return \"location\"; }\r\nResults:\r\nget 'test'\t\t\t\tok\r\nget 'test/1'\t\t\tok\r\nget 'test/location'\t\tERR (returns \"index\")\r\nget 'test/location/1'\tERR (NotFoundHttpException)\r\n```\r\n\r\nI can see that mostly the 'location' errors are triggered because 'location' is interpreted as an argument. However, i'm pretty sure that this behaviour was different in 4.x branch."}}