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 96d9ac5 commit 15586faCopy full SHA for 15586fa
src/Illuminate/Database/Eloquent/Collection.php
@@ -642,7 +642,15 @@ public function toQuery()
642
$model = $this->first();
643
644
if (! $model) {
645
- throw new LogicException('can not get Eloquent QueryBuilder from an empty Collection.');
+ throw new LogicException('Unable to create query for empty collection.');
646
+ }
647
+
648
+ $class = get_class($model);
649
650
+ if ($this->filter(function ($model) use ($class) {
651
+ return ! $model instanceof $class;
652
+ })->isNotEmpty()) {
653
+ throw new LogicException('Unable to create query for collection with mixed types.');
654
}
655
656
return $model->newModelQuery()->whereKey($this->modelKeys());
0 commit comments