#1605·api

parameters attribute not work in resource route

Author: xuchang-xCreated Nov 28, 2018Updated Nov 7, 2021
Q A
Bug? yes
New Feature? no
Framework Laravel
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