@@ -577,7 +577,16 @@ public function pluck($column, $key = null)
577
577
{
578
578
$ results = $ this ->get (is_null ($ key ) ? [$ column ] : [$ column , $ key ]);
579
579
580
- return $ this ->useCollections ? $ results ->pluck ($ column , $ key ) : Arr::pluck ($ results , $ column , $ key );
580
+ // Convert ObjectID's to strings
581
+ if ($ key == '_id ' ) {
582
+ $ results = $ results ->map (function ($ item ) {
583
+ $ item ['_id ' ] = (string )$ item ['_id ' ];
584
+ return $ item ;
585
+ });
586
+ }
587
+
588
+ $ p = Arr::pluck ($ results , $ column , $ key );
589
+ return $ this ->useCollections ? new Collection ($ p ) : $ p ;
581
590
}
582
591
583
592
/**
@@ -632,20 +641,7 @@ public function truncate()
632
641
*/
633
642
public function lists ($ column , $ key = null )
634
643
{
635
- if ($ key == '_id ' ) {
636
- $ results = new Collection ($ this ->get ([$ column , $ key ]));
637
-
638
- // Convert ObjectID's to strings so that lists can do its work.
639
- $ results = $ results ->map (function ($ item ) {
640
- $ item ['_id ' ] = (string ) $ item ['_id ' ];
641
-
642
- return $ item ;
643
- });
644
-
645
- return $ results ->pluck ($ column , $ key )->all ();
646
- }
647
-
648
- return parent ::pluck ($ column , $ key );
644
+ return $ this ->pluck ($ column , $ key );
649
645
}
650
646
651
647
/**
@@ -1038,4 +1034,4 @@ public function __call($method, $parameters)
1038
1034
1039
1035
return parent ::__call ($ method , $ parameters );
1040
1036
}
1041
- }
1037
+ }
0 commit comments