diff --git a/.gitignore b/.gitignore index fce6c79..2a9b83a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /vendor composer.phar .DS_Store +.idea/ +.idea/workspace.xml \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..32054c7 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + true + + + + DIRECTORY + + false + + + + + + + + + 1504120043462 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Efficiently/AuthorityController/Parameters.php b/src/Efficiently/AuthorityController/Parameters.php index 2d52f5e..09235d4 100644 --- a/src/Efficiently/AuthorityController/Parameters.php +++ b/src/Efficiently/AuthorityController/Parameters.php @@ -46,11 +46,12 @@ public function fillController($controller) if ($lastRouteParamKey === 'id' || $resourceId === str_singular($lastRouteParamKey)) { $id = last($routeParams); if (is_a($id, 'Illuminate\Database\Eloquent\Model')) { + $object = $id; $id = $id->getKey(); } if (is_string($id) || is_numeric($id)) { array_pop($routeParams); - $routeParamsParsed['id'] = $id; + $routeParamsParsed[$object->getKeyName()] = $id; } } diff --git a/tests/AcParametersTest.php b/tests/AcParametersTest.php index fce3f6b..c037851 100644 --- a/tests/AcParametersTest.php +++ b/tests/AcParametersTest.php @@ -159,6 +159,8 @@ public function testResolveResourceIdFromRequest() $this->call('GET', '/projects/5');// show action + dd($this->parameters, $this->call('GET', '/projects/5')); + $this->assertArrayHasKey('id', $this->getProperty($parameters, 'params')); $this->assertEquals($this->getProperty($parameters, 'params')['id'], '5');