Skip to content

Commit

Permalink
Merge pull request #1661 from Zuken/fix_where_in
Browse files Browse the repository at this point in the history
Replaced whereIn method retrieval for relations
  • Loading branch information
jenssegers committed Nov 29, 2018
2 parents b69ef21 + 4c1ce51 commit 9df6d1e
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Jenssegers\Mongodb\Relations;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model as EloquentModel;

class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
{
Expand Down Expand Up @@ -59,4 +60,16 @@ public function getOwnerKey()
{
return property_exists($this, 'ownerKey') ? $this->ownerKey : $this->otherKey;
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany;
use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Model as EloquentModel;

class BelongsToMany extends EloquentBelongsToMany
{
Expand Down Expand Up @@ -337,4 +338,16 @@ public function getRelatedKey()
{
return property_exists($this, 'relatedPivotKey') ? $this->relatedPivotKey : $this->relatedKey;
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/EmbedsMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use MongoDB\BSON\ObjectID;
use Illuminate\Database\Eloquent\Model as EloquentModel;

class EmbedsMany extends EmbedsOneOrMany
{
Expand Down Expand Up @@ -328,4 +329,16 @@ public function __call($method, $parameters)

return parent::__call($method, $parameters);
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/EmbedsOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Model;
use MongoDB\BSON\ObjectID;
use Illuminate\Database\Eloquent\Model as EloquentModel;

class EmbedsOne extends EmbedsOneOrMany
{
Expand Down Expand Up @@ -136,4 +137,16 @@ public function delete()
{
return $this->performDelete();
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation;
use Jenssegers\Mongodb\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as EloquentModel;

abstract class EmbedsOneOrMany extends Relation
{
Expand Down Expand Up @@ -403,4 +404,16 @@ public function getQualifiedForeignKeyName()
{
return $this->foreignKey;
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany as EloquentHasMany;
use Illuminate\Database\Eloquent\Model as EloquentModel;

class HasMany extends EloquentHasMany
{
Expand Down Expand Up @@ -77,4 +78,16 @@ public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*

return $query->where($this->getHasCompareKey(), 'exists', true);
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasOne as EloquentHasOne;
use Illuminate\Database\Eloquent\Model as EloquentModel;

class HasOne extends EloquentHasOne
{
Expand Down Expand Up @@ -77,4 +78,16 @@ public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*

return $query->where($this->getForeignKeyName(), 'exists', true);
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
13 changes: 13 additions & 0 deletions src/Jenssegers/Mongodb/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Jenssegers\Mongodb\Relations;

use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo;
use Illuminate\Database\Eloquent\Model as EloquentModel;

class MorphTo extends EloquentMorphTo
{
Expand Down Expand Up @@ -42,4 +43,16 @@ public function getOwnerKey()
{
return property_exists($this, 'ownerKey') ? $this->ownerKey : $this->otherKey;
}

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}

0 comments on commit 9df6d1e

Please sign in to comment.