File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 3
3
All notable changes to this project will be documented in this file. This project adheres to
4
4
[ Semantic Versioning] ( http://semver.org/ ) and [ this changelog format] ( http://keepachangelog.com/ ) .
5
5
6
+ ## Unreleased
7
+
8
+ ### Fixed
9
+
10
+ - [ #178 ] ( https://github.com/laravel-json-api/laravel/issues/178 ) Allow a resource id that is ` "0" ` .
11
+
6
12
## [ 2.1.0] - 2022-02-20
7
13
8
14
### Added
Original file line number Diff line number Diff line change 25
25
"require" : {
26
26
"php" : " ^7.4|^8.0" ,
27
27
"ext-json" : " *" ,
28
- "laravel-json-api/core" : " ^2.1 " ,
28
+ "laravel-json-api/core" : " ^2.2 " ,
29
29
"laravel-json-api/eloquent" : " ^2.1" ,
30
30
"laravel-json-api/encoder-neomerx" : " ^2.0" ,
31
31
"laravel-json-api/exceptions" : " ^1.1" ,
32
- "laravel-json-api/spec" : " ^1.1" ,
32
+ "laravel-json-api/spec" : " ^1.1.1 " ,
33
33
"laravel-json-api/validation" : " ^2.0" ,
34
34
"laravel/framework" : " ^8.76|^9.0"
35
35
},
Original file line number Diff line number Diff line change 27
27
use LaravelJsonApi \Contracts \Schema \Relation ;
28
28
use LaravelJsonApi \Contracts \Schema \Schema ;
29
29
use LaravelJsonApi \Contracts \Server \Server ;
30
+ use LaravelJsonApi \Core \Document \ResourceIdentifier ;
30
31
use LogicException ;
31
32
use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
32
33
@@ -101,11 +102,11 @@ public function modelOrResourceId()
101
102
102
103
$ modelOrResourceId = $ this ->route ->parameter ($ name );
103
104
104
- if (!empty ($ modelOrResourceId ) || ' 0 ' === $ modelOrResourceId ) {
105
- return $ modelOrResourceId ;
105
+ if (!is_object ($ modelOrResourceId ) && ResourceIdentifier:: idIsEmpty ( $ modelOrResourceId) ) {
106
+ throw new LogicException ( ' No JSON API resource id set on route. ' ) ;
106
107
}
107
108
108
- throw new LogicException ( ' No JSON API resource id set on route. ' ) ;
109
+ return $ modelOrResourceId ;
109
110
}
110
111
111
112
/**
You can’t perform that action at this time.
0 commit comments