This repository was archived by the owner on Feb 14, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -65,20 +65,19 @@ protected function attachRelations(Model $model)
6565 /**
6666 * Process a model relation attaching to its model additional attributes.
6767 *
68- * @param \Illuminate\Database\Eloquent\Model $relation
68+ * @param \Illuminate\Database\Eloquent\Model $model
6969 * @return array
7070 */
71- protected function processModelRelation (Model $ relation )
71+ protected function processModelRelation (Model $ model )
7272 {
73- if (count (array_filter ($ relation ->getRelations ())) > 0 ) {
74- $ this ->attachRelations ($ relation );
75- $ relation ->setRelations ([]);
76- }
73+ $ modelResource = new JsonApiResource ($ model , $ this ->authorize );
7774
78- $ relationResource = new JsonApiResource ( $ relation , $ this -> authorize ) ;
75+ $ this -> with [ ' included ' ][] = $ modelResource ;
7976
80- $ this ->with ['included ' ][] = $ relationResource ;
77+ if (Arr::has ($ modelResource ->with , 'included ' )) {
78+ $ this ->with ['included ' ][] = $ modelResource ->with ['included ' ];
79+ }
8180
82- return $ relationResource ->getResourceIdentifier ();
81+ return $ modelResource ->getResourceIdentifier ();
8382 }
8483}
You can’t perform that action at this time.
0 commit comments