12
12
namespace Tobyz \JsonApiServer \Adapter ;
13
13
14
14
use Closure ;
15
+ use Illuminate \Database \Eloquent \Builder ;
15
16
use Illuminate \Database \Eloquent \Collection ;
16
17
use Illuminate \Database \Eloquent \Model ;
17
18
use Illuminate \Database \Eloquent \Relations \BelongsTo ;
18
19
use Illuminate \Database \Eloquent \Relations \BelongsToMany ;
19
- use Illuminate \Database \Eloquent \Relations \HasOneThrough ;
20
- use Illuminate \Database \Eloquent \Relations \MorphOneOrMany ;
21
20
use InvalidArgumentException ;
22
21
use Tobyz \JsonApiServer \Context ;
23
22
use Tobyz \JsonApiServer \Deferred ;
@@ -42,7 +41,7 @@ public function __construct($model)
42
41
}
43
42
}
44
43
45
- public function query ()
44
+ public function query (): Builder
46
45
{
47
46
return $ this ->model ->query ();
48
47
}
@@ -97,13 +96,13 @@ public function getAttribute($model, Attribute $attribute)
97
96
return $ model ->getAttribute ($ this ->getAttributeProperty ($ attribute ));
98
97
}
99
98
100
- public function getHasOne ($ model , HasOne $ relationship , bool $ linkage , Context $ context )
99
+ public function getHasOne ($ model , HasOne $ relationship , bool $ linkageOnly , Context $ context )
101
100
{
102
101
// If this is a belongs-to relationship, and we only need to get the ID
103
102
// for linkage, then we don't have to actually load the relation because
104
103
// the ID is stored in a column directly on the model. We will mock up a
105
104
// related model with the value of the ID filled.
106
- if ($ linkage ) {
105
+ if ($ linkageOnly ) {
107
106
$ relation = $ this ->getEloquentRelation ($ model , $ relationship );
108
107
109
108
if ($ relation instanceof BelongsTo) {
@@ -122,7 +121,7 @@ public function getHasOne($model, HasOne $relationship, bool $linkage, Context $
122
121
return $ this ->getRelationship ($ model , $ relationship , $ context );
123
122
}
124
123
125
- public function getHasMany ($ model , HasMany $ relationship , bool $ linkage , Context $ context )
124
+ public function getHasMany ($ model , HasMany $ relationship , bool $ linkageOnly , Context $ context )
126
125
{
127
126
return $ this ->getRelationship ($ model , $ relationship , $ context );
128
127
}
@@ -147,7 +146,7 @@ public function represents($model): bool
147
146
return $ model instanceof $ this ->model ;
148
147
}
149
148
150
- public function model ()
149
+ public function model (): Model
151
150
{
152
151
return $ this ->model ->newInstance ();
153
152
}
0 commit comments