Unverified Commit 9df75b74 authored by Jens Segers's avatar Jens Segers Committed by GitHub

Merge pull request #1487 from benargo/wherehas

 Fix #1293: Exception: BelongsToMany Is Not supported for hybrid query constraints! #1324 
parents 9e4786cc 6d4888a2
......@@ -4,6 +4,7 @@ namespace Jenssegers\Mongodb\Helpers;
use Closure;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
use Jenssegers\Mongodb\Eloquent\Model;
......@@ -112,7 +113,11 @@ trait QueriesRelationships
return $relation->getForeignKey();
}
throw new \Exception(class_basename($relation) . ' Is Not supported for hybrid query constraints!');
if ($relation instanceof BelongsToMany && ! $this->isAcrossConnections($relation)) {
return $this->model->getKeyName();
}
throw new \Exception(class_basename($relation) . ' is not supported for hybrid query constraints.');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment