77use Illuminate \Support \Arr ;
88use Illuminate \Support \Str ;
99use InvalidArgumentException ;
10- use Illuminate \Support \Collection ;
1110use Illuminate \Pagination \Paginator ;
1211use Illuminate \Support \Traits \Macroable ;
1312use Illuminate \Contracts \Support \Arrayable ;
@@ -1543,11 +1542,9 @@ public function chunk($count, callable $callback)
15431542 */
15441543 public function pluck ($ column , $ key = null )
15451544 {
1546- $ columns = $ this ->getPluckSelect ( $ column , $ key );
1545+ $ results = $ this ->get ( func_get_args () );
15471546
1548- $ results = new Collection ($ this ->get ($ columns ));
1549-
1550- return $ results ->pluck ($ columns [0 ], Arr::get ($ columns , 1 ))->all ();
1547+ return Arr::pluck ($ results , $ this ->stripTable ($ column ), $ this ->stripTable ($ key ));
15511548 }
15521549
15531550 /**
@@ -1565,24 +1562,14 @@ public function lists($column, $key = null)
15651562 }
15661563
15671564 /**
1568- * Get the columns that should be used in a pluck select .
1565+ * Strip off the table name from a column identifier .
15691566 *
15701567 * @param string $column
1571- * @param string $key
1572- * @return array
1568+ * @return string
15731569 */
1574- protected function getPluckSelect ($ column, $ key )
1570+ protected function stripTable ($ column )
15751571 {
1576- $ select = is_null ($ key ) ? [$ column ] : [$ column , $ key ];
1577-
1578- // If the selected columns contain "dots", we will remove it so that the pluck
1579- // operation can run normally. Specifying the table is not needed, since we
1580- // really want the names of the columns as it is in this resulting array.
1581- return array_map (function ($ column ) {
1582- $ dot = strpos ($ column , '. ' );
1583-
1584- return $ dot === false ? $ column : substr ($ column , $ dot + 1 );
1585- }, $ select );
1572+ return is_null ($ column ) ? $ column : last (explode ('. ' , $ column ));
15861573 }
15871574
15881575 /**
0 commit comments