Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Move the getRelationCountHash method to parent class (Relation) #35394

Merged
merged 3 commits into from Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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