Skip to content

Commit 15586fa

Browse files
committed
formatting
1 parent 96d9ac5 commit 15586fa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Illuminate/Database/Eloquent/Collection.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,15 @@ public function toQuery()
642642
$model = $this->first();
643643

644644
if (! $model) {
645-
throw new LogicException('can not get Eloquent QueryBuilder from an empty Collection.');
645+
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.');
646654
}
647655

648656
return $model->newModelQuery()->whereKey($this->modelKeys());

0 commit comments

Comments
 (0)