We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45a0c7a commit 5d229ebCopy full SHA for 5d229eb
src/Relations/MorphToMany.php
@@ -393,15 +393,17 @@ protected function whereInMethod(Model $model, $key)
393
*
394
* @return mixed
395
*/
396
- private function extractIds(array $data, ?string $relatedPivotKey = null)
+ public function extractIds(array $data, ?string $relatedPivotKey = null)
397
{
398
$relatedPivotKey = $relatedPivotKey ?: $this->relatedPivotKey;
399
- return array_reduce($data, function ($carry, $item) use ($relatedPivotKey) {
+ $result = array_reduce($data, function ($carry, $item) use ($relatedPivotKey) {
400
if (is_array($item) && array_key_exists($relatedPivotKey, $item)) {
401
$carry[] = $item[$relatedPivotKey];
402
}
403
404
return $carry;
405
}, []);
406
+
407
+ return array_values(array_unique($result));
408
409
0 commit comments