Skip to content

Commit 9133ba4

Browse files
committed
Remove deprecated lists
1 parent 9616f09 commit 9133ba4

File tree

2 files changed

+29
-37
lines changed

2 files changed

+29
-37
lines changed

src/Jenssegers/Mongodb/Eloquent/Builder.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ class Builder extends EloquentBuilder
1313
* @var array
1414
*/
1515
protected $passthru = [
16-
'toSql', 'lists', 'insert', 'insertGetId', 'pluck',
16+
'toSql', 'insert', 'insertGetId', 'pluck',
1717
'count', 'min', 'max', 'avg', 'sum', 'exists', 'push', 'pull',
1818
];
1919

2020
/**
2121
* Update a record in the database.
2222
*
23-
* @param array $values
24-
* @param array $options
23+
* @param array $values
24+
* @param array $options
2525
* @return int
2626
*/
2727
public function update(array $values, array $options = [])
@@ -40,7 +40,7 @@ public function update(array $values, array $options = [])
4040
/**
4141
* Insert a new record into the database.
4242
*
43-
* @param array $values
43+
* @param array $values
4444
* @return bool
4545
*/
4646
public function insert(array $values)
@@ -59,8 +59,8 @@ public function insert(array $values)
5959
/**
6060
* Insert a new record and get the value of the primary key.
6161
*
62-
* @param array $values
63-
* @param string $sequence
62+
* @param array $values
63+
* @param string $sequence
6464
* @return int
6565
*/
6666
public function insertGetId(array $values, $sequence = null)
@@ -97,9 +97,9 @@ public function delete()
9797
/**
9898
* Increment a column's value by a given amount.
9999
*
100-
* @param string $column
101-
* @param int $amount
102-
* @param array $extra
100+
* @param string $column
101+
* @param int $amount
102+
* @param array $extra
103103
* @return int
104104
*/
105105
public function increment($column, $amount = 1, array $extra = [])
@@ -127,9 +127,9 @@ public function increment($column, $amount = 1, array $extra = [])
127127
/**
128128
* Decrement a column's value by a given amount.
129129
*
130-
* @param string $column
131-
* @param int $amount
132-
* @param array $extra
130+
* @param string $column
131+
* @param int $amount
132+
* @param array $extra
133133
* @return int
134134
*/
135135
public function decrement($column, $amount = 1, array $extra = [])
@@ -155,19 +155,21 @@ public function decrement($column, $amount = 1, array $extra = [])
155155
/**
156156
* Add the "has" condition where clause to the query.
157157
*
158-
* @param \Illuminate\Database\Eloquent\Builder $hasQuery
159-
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
160-
* @param string $operator
161-
* @param int $count
162-
* @param string $boolean
158+
* @param \Illuminate\Database\Eloquent\Builder $hasQuery
159+
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
160+
* @param string $operator
161+
* @param int $count
162+
* @param string $boolean
163163
* @return \Illuminate\Database\Eloquent\Builder
164164
*/
165165
protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $operator, $count, $boolean)
166166
{
167167
$query = $hasQuery->getQuery();
168168

169169
// Get the number of related objects for each possible parent.
170-
$relationCount = array_count_values($query->lists($relation->getHasCompareKey()));
170+
$relationCount = array_count_values(array_map(function ($id) {
171+
return (string)$id; // Convert Back ObjectIds to Strings
172+
}, $query->pluck($relation->getHasCompareKey())));
171173

172174
// Remove unwanted related objects based on the operator and count.
173175
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator) {
@@ -207,7 +209,7 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
207209
/**
208210
* Create a raw database expression.
209211
*
210-
* @param closure $expression
212+
* @param closure $expression
211213
* @return mixed
212214
*/
213215
public function raw($expression = null)
@@ -219,17 +221,13 @@ public function raw($expression = null)
219221
if ($results instanceof Cursor) {
220222
$results = iterator_to_array($results, false);
221223
return $this->model->hydrate($results);
222-
}
223-
224-
// Convert Mongo BSONDocument to a single object.
224+
} // Convert Mongo BSONDocument to a single object.
225225
elseif ($results instanceof BSONDocument) {
226226
$results = $results->getArrayCopy();
227-
return $this->model->newFromBuilder((array) $results);
228-
}
229-
230-
// The result is a single object.
227+
return $this->model->newFromBuilder((array)$results);
228+
} // The result is a single object.
231229
elseif (is_array($results) and array_key_exists('_id', $results)) {
232-
return $this->model->newFromBuilder((array) $results);
230+
return $this->model->newFromBuilder((array)$results);
233231
}
234232

235233
return $results;

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,7 @@ public function pluck($column, $key = null)
569569
{
570570
$results = $this->get(is_null($key) ? [$column] : [$column, $key]);
571571

572-
// If the columns are qualified with a table or have an alias, we cannot use
573-
// those directly in the "pluck" operations since the results from the DB
574-
// are only keyed by the column itself. We'll strip the table out here.
575-
return Arr::pluck(
576-
$results,
577-
$column,
578-
$key
579-
);
572+
return $results->pluck($column,$key);
580573
}
581574

582575
/**
@@ -624,6 +617,7 @@ public function truncate()
624617
/**
625618
* Get an array with the values of a given column.
626619
*
620+
* @deprecated
627621
* @param string $column
628622
* @param string $key
629623
* @return array
@@ -640,10 +634,10 @@ public function lists($column, $key = null)
640634
return $item;
641635
});
642636

643-
return $results->lists($column, $key)->all();
637+
return $results->pluck($column, $key)->all();
644638
}
645639

646-
return parent::lists($column, $key);
640+
return parent::pluck($column, $key);
647641
}
648642

649643
/**

0 commit comments

Comments
 (0)