Skip to content

Commit

Permalink
[8.x] Move the getRelationCountHash method to parent class (Relation) (
Browse files Browse the repository at this point in the history
…#35394)

* Move the getRelationCountHash method to parent class (relation)

* Rename the getRelationCountHash parameter to incrementJoinCount
  • Loading branch information
khalilst committed Nov 29, 2020
1 parent d12b613 commit 2b4b18c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 72 deletions.
18 changes: 0 additions & 18 deletions src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Expand Up @@ -40,13 +40,6 @@ class BelongsTo extends Relation
*/
protected $relationName;

/**
* The count of self joins.
*
* @var int
*/
protected static $selfJoinCount = 0;

/**
* Create a new belongs to relationship instance.
*
Expand Down Expand Up @@ -279,17 +272,6 @@ public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder
);
}

/**
* Get a relationship join table hash.
*
* @param bool $incrementJoinCount
* @return string
*/
public function getRelationCountHash($incrementJoinCount = true)
{
return 'laravel_reserved_'.($incrementJoinCount ? static::$selfJoinCount++ : static::$selfJoinCount);
}

/**
* Determine if the related model has an auto-incrementing ID.
*
Expand Down
18 changes: 0 additions & 18 deletions src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
Expand Up @@ -127,13 +127,6 @@ class BelongsToMany extends Relation
*/
protected $accessor = 'pivot';

/**
* The count of self joins.
*
* @var int
*/
protected static $selfJoinCount = 0;

/**
* Create a new belongs to many relationship instance.
*
Expand Down Expand Up @@ -1167,17 +1160,6 @@ public function getExistenceCompareKey()
return $this->getQualifiedForeignPivotKeyName();
}

/**
* Get a relationship join table hash.
*
* @param bool $incrementJoinCount
* @return string
*/
public function getRelationCountHash($incrementJoinCount = true)
{
return 'laravel_reserved_'.($incrementJoinCount ? static::$selfJoinCount++ : static::$selfJoinCount);
}

/**
* Specify that the pivot table has creation and update timestamps.
*
Expand Down
18 changes: 0 additions & 18 deletions src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
Expand Up @@ -53,13 +53,6 @@ class HasManyThrough extends Relation
*/
protected $secondLocalKey;

/**
* The count of self joins.
*
* @var int
*/
protected static $selfJoinCount = 0;

/**
* Create a new has many through relationship instance.
*
Expand Down Expand Up @@ -596,17 +589,6 @@ public function getRelationExistenceQueryForThroughSelfRelation(Builder $query,
);
}

/**
* Get a relationship join table hash.
*
* @param bool $incrementJoinCount
* @return string
*/
public function getRelationCountHash($incrementJoinCount = true)
{
return 'laravel_reserved_'.($incrementJoinCount ? static::$selfJoinCount++ : static::$selfJoinCount);
}

/**
* Get the qualified foreign key on the related model.
*
Expand Down
18 changes: 0 additions & 18 deletions src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
Expand Up @@ -22,13 +22,6 @@ abstract class HasOneOrMany extends Relation
*/
protected $localKey;

/**
* The count of self joins.
*
* @var int
*/
protected static $selfJoinCount = 0;

/**
* Create a new has one or many relationship instance.
*
Expand Down Expand Up @@ -363,17 +356,6 @@ public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder
);
}

/**
* Get a relationship join table hash.
*
* @param bool $incrementJoinCount
* @return string
*/
public function getRelationCountHash($incrementJoinCount = true)
{
return 'laravel_reserved_'.($incrementJoinCount ? static::$selfJoinCount++ : static::$selfJoinCount);
}

/**
* Get the key for comparing against the parent key in "has" query.
*
Expand Down
18 changes: 18 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/Relation.php
Expand Up @@ -62,6 +62,13 @@ abstract class Relation
*/
public static $tableNameAsMorphType = false;

/**
* The count of self joins.
*
* @var int
*/
protected static $selfJoinCount = 0;

/**
* Create a new relation instance.
*
Expand Down Expand Up @@ -220,6 +227,17 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
);
}

/**
* Get a relationship join table hash.
*
* @param bool $incrementJoinCount
* @return string
*/
public function getRelationCountHash($incrementJoinCount = true)
{
return 'laravel_reserved_'.($incrementJoinCount ? static::$selfJoinCount++ : static::$selfJoinCount);
}

/**
* Get all of the primary keys for an array of models.
*
Expand Down

0 comments on commit 2b4b18c

Please sign in to comment.