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 +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,7 @@ public function toArray($request)
53
53
return [
54
54
$ this ->merge ($ this ->getResourceIdentifier ()),
55
55
'attributes ' => $ this ->getAttributes (),
56
- 'relationships ' => $ this ->when (
57
- $ this ->relationships , $ this ->relationships
58
- ),
56
+ 'relationships ' => $ this ->when ($ this ->relationships , $ this ->relationships ),
59
57
];
60
58
}
61
59
@@ -94,8 +92,22 @@ public function getResourceIdentifier()
94
92
*/
95
93
protected function getAttributes ()
96
94
{
97
- return array_filter ($ this ->resource ->attributesToArray (), function ($ key ) {
98
- return !Str::endsWith ($ key , '_id ' ) && $ key !== $ this ->resource ->getKeyName ();
99
- }, ARRAY_FILTER_USE_KEY );
95
+ return array_filter (
96
+ array_merge ($ this ->resource ->attributesToArray (), $ this ->withAttributes ()),
97
+ function ($ value , $ key ) {
98
+ return !Str::endsWith ($ key , '_id ' ) && $ key !== $ this ->resource ->getKeyName () && !is_null ($ value );
99
+ },
100
+ ARRAY_FILTER_USE_BOTH
101
+ );
102
+ }
103
+
104
+ /**
105
+ * Attach additional attributes data.
106
+ *
107
+ * @return array
108
+ */
109
+ protected function withAttributes ()
110
+ {
111
+ return [];
100
112
}
101
113
}
You can’t perform that action at this time.
0 commit comments