dingo / dingo/api

parameters attribute not work in resource route

Open
#1,605 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
9.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

| Q | A
| ----------------- | ---
| Bug? |yes
| New Feature? | no
| Framework | Laravel|Lumen
| Framework version | 5.6.38
| Package version | v2.0.0-alpha2
| PHP version | 7.2.10

#### Actual Behaviour

i write two resource route with parameters attribute like this
```
$api->resource('apply', 'ProjectApplicationController', [
'only' => ['store', 'show', 'index', 'destroy'],
'parameters' => ['apply' => 'application'],
]);

$api->resource('applicationPage', 'ProjectApplicationPageController', [
'only' => ['store', 'show', 'index'],
'parameters' => ['applicationPage' => 'aaa'],
]);
```
i can get the entity in the first route controller like this
`public function show(ProjectApplication $application)`
but i can't get the other one with the code
`public function show(Request $request, ProjectApplicationPage $aaa)`

and i've test several ways to fix this problem like change the routes like this
```
$api->resource('apply', 'ProjectApplicationController', [
'only' => ['store', 'show', 'index', 'destroy'],
'parameters' => ['apply' => 'application','applicationPage' => 'aaa'],
]);

$api->resource('applicationPage', 'ProjectApplicationPageController', [
'only' => ['store', 'show', 'index'],
]);
```
or i can get my second entity when i delete my first route's parameters attribute, so i guess the 'parameters' attribute was resolved only once.
#### Expected Behaviour

i just prefer to config the attribute at the specified route, instead of put them together.

#### Possible Solutions

Just scan all the 'parameters' attributes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.