File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
src/Illuminate/Http/Resources/Json Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -78,13 +78,24 @@ public static function make(...$parameters)
78
78
*/
79
79
public static function collection ($ resource )
80
80
{
81
- return tap (new AnonymousResourceCollection ( $ resource , static ::class ), function ($ collection ) {
81
+ return tap (static ::newCollection ( $ resource ), function ($ collection ) {
82
82
if (property_exists (static ::class, 'preserveKeys ' )) {
83
83
$ collection ->preserveKeys = (new static ([]))->preserveKeys === true ;
84
84
}
85
85
});
86
86
}
87
87
88
+ /**
89
+ * Create a new resource collection instance.
90
+ *
91
+ * @param mixed $resource
92
+ * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
93
+ */
94
+ protected static function newCollection ($ resource )
95
+ {
96
+ return new AnonymousResourceCollection ($ resource , static ::class);
97
+ }
98
+
88
99
/**
89
100
* Resolve the resource to an array.
90
101
*
You can’t perform that action at this time.
0 commit comments