dingo / dingo/api

Laravel 5.5 Resource routing can not bind model

Open
#1,506 4 comments 3 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? | no
| New Feature? | yes
| Framework | Laravel
| Framework version | 5.5
| Package version | 2.0.0-alpha1
| PHP version | 7.0.20

#### Actual Behaviour

I do the following settings in the routing
```
$api->version('v1', ['namespace' => 'App\Http\Api\V1\Controllers'], function ($api) {
$api->resource('applys', 'ApplysController');
});
```
I am on the controller below
```
public function destroy(Apply $apply)
{
return $apply;
}
```
My request http://www.demo.com/api/applys/11 Get the structure is null, but in fact there is data
But when I route the following settings, the structure is normal
```
Route::resource('applys', '\App\Http\Api\V1\Controllers\ApplysController');
```
And the following is also problematic
```
$api->version('v1', ['namespace' => 'App\Http\Api\V1\Controllers'], function ($api) {
$api->get('applys/{applys}', function (\App\Models\Apply $apply) {
return $apply->id; // The big one here is null
})
});
```

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.