File tree Expand file tree Collapse file tree 1 file changed +22
-16
lines changed
Expand file tree Collapse file tree 1 file changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -55,25 +55,31 @@ public static function load(
5555 $ constrain = [];
5656
5757 foreach ($ resources as $ resource ) {
58+ if (!$ resource instanceof EloquentResource) {
59+ continue ;
60+ }
61+
5862 $ modelClass = get_class ($ resource ->newModel ($ context ));
5963
60- if ($ resource instanceof EloquentResource && !isset ($ constrain [$ modelClass ])) {
61- $ constrain [$ modelClass ] = function ($ query ) use (
62- $ resource ,
63- $ context ,
64- $ relationship ,
65- ) {
66- $ resource ->scope ($ query , $ context );
67-
68- if (
69- ($ relationship instanceof ToMany ||
70- $ relationship instanceof ToOne) &&
71- $ relationship ->scope
72- ) {
73- ($ relationship ->scope )($ query , $ context );
74- }
75- };
64+ if (isset ($ constrain [$ modelClass ])) {
65+ continue ;
7666 }
67+
68+ $ constrain [$ modelClass ] = function ($ query ) use (
69+ $ resource ,
70+ $ context ,
71+ $ relationship ,
72+ ) {
73+ $ resource ->scope ($ query , $ context );
74+
75+ if (
76+ ($ relationship instanceof ToMany ||
77+ $ relationship instanceof ToOne) &&
78+ $ relationship ->scope
79+ ) {
80+ ($ relationship ->scope )($ query , $ context );
81+ }
82+ };
7783 }
7884
7985 if ($ relation instanceof MorphTo) {
You can’t perform that action at this time.
0 commit comments