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

[12.x] do not use mix of newline and inline formatting #54967

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 98 additions & 30 deletions src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,13 @@ public function hasOneThrough($related, $through, $firstKey = null, $secondKey =
$secondKey = $secondKey ?: $through->getForeignKey();

return $this->newHasOneThrough(
$this->newRelatedInstance($related)->newQuery(), $this, $through,
$firstKey, $secondKey, $localKey ?: $this->getKeyName(),
$secondLocalKey ?: $through->getKeyName()
$this->newRelatedInstance($related)->newQuery(),
$this,
$through,
$firstKey,
$secondKey,
$localKey ?: $this->getKeyName(),
$secondLocalKey ?: $through->getKeyName(),
);
}

Expand Down Expand Up @@ -562,9 +566,15 @@ protected function newMorphMany(Builder $query, Model $parent, $type, $id, $loca
* @param string|null $relation
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<TRelatedModel, $this>
*/
public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null,
$parentKey = null, $relatedKey = null, $relation = null)
{
public function belongsToMany(
$related,
$table = null,
$foreignPivotKey = null,
$relatedPivotKey = null,
$parentKey = null,
$relatedKey = null,
$relation = null,
) {
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply.
Expand All @@ -589,9 +599,14 @@ public function belongsToMany($related, $table = null, $foreignPivotKey = null,
}

return $this->newBelongsToMany(
$instance->newQuery(), $this, $table, $foreignPivotKey,
$relatedPivotKey, $parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(), $relation
$instance->newQuery(),
$this,
$table,
$foreignPivotKey,
$relatedPivotKey,
$parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(),
$relation,
);
}

Expand All @@ -611,9 +626,16 @@ public function belongsToMany($related, $table = null, $foreignPivotKey = null,
* @param string|null $relationName
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<TRelatedModel, TDeclaringModel>
*/
protected function newBelongsToMany(Builder $query, Model $parent, $table, $foreignPivotKey, $relatedPivotKey,
$parentKey, $relatedKey, $relationName = null)
{
protected function newBelongsToMany(
Builder $query,
Model $parent,
$table,
$foreignPivotKey,
$relatedPivotKey,
$parentKey,
$relatedKey,
$relationName = null,
) {
return new BelongsToMany($query, $parent, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey, $relationName);
}

Expand All @@ -633,10 +655,17 @@ protected function newBelongsToMany(Builder $query, Model $parent, $table, $fore
* @param bool $inverse
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<TRelatedModel, $this>
*/
public function morphToMany($related, $name, $table = null, $foreignPivotKey = null,
$relatedPivotKey = null, $parentKey = null,
$relatedKey = null, $relation = null, $inverse = false)
{
public function morphToMany(
$related,
$name,
$table = null,
$foreignPivotKey = null,
$relatedPivotKey = null,
$parentKey = null,
$relatedKey = null,
$relation = null,
$inverse = false,
) {
$relation = $relation ?: $this->guessBelongsToManyRelation();

// First, we will need to determine the foreign key and "other key" for the
Expand All @@ -660,9 +689,16 @@ public function morphToMany($related, $name, $table = null, $foreignPivotKey = n
}

return $this->newMorphToMany(
$instance->newQuery(), $this, $name, $table,
$foreignPivotKey, $relatedPivotKey, $parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(), $relation, $inverse
$instance->newQuery(),
$this,
$name,
$table,
$foreignPivotKey,
$relatedPivotKey,
$parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(),
$relation,
$inverse,
);
}

Expand All @@ -684,12 +720,30 @@ public function morphToMany($related, $name, $table = null, $foreignPivotKey = n
* @param bool $inverse
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<TRelatedModel, TDeclaringModel>
*/
protected function newMorphToMany(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
$relatedPivotKey, $parentKey, $relatedKey,
$relationName = null, $inverse = false)
{
return new MorphToMany($query, $parent, $name, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey,
$relationName, $inverse);
protected function newMorphToMany(
Builder $query,
Model $parent,
$name,
$table,
$foreignPivotKey,
$relatedPivotKey,
$parentKey,
$relatedKey,
$relationName = null,
$inverse = false,
) {
return new MorphToMany(
$query,
$parent,
$name,
$table,
$foreignPivotKey,
$relatedPivotKey,
$parentKey,
$relatedKey,
$relationName,
$inverse,
);
}

/**
Expand All @@ -707,9 +761,16 @@ protected function newMorphToMany(Builder $query, Model $parent, $name, $table,
* @param string|null $relation
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<TRelatedModel, $this>
*/
public function morphedByMany($related, $name, $table = null, $foreignPivotKey = null,
$relatedPivotKey = null, $parentKey = null, $relatedKey = null, $relation = null)
{
public function morphedByMany(
$related,
$name,
$table = null,
$foreignPivotKey = null,
$relatedPivotKey = null,
$parentKey = null,
$relatedKey = null,
$relation = null,
) {
$foreignPivotKey = $foreignPivotKey ?: $this->getForeignKey();

// For the inverse of the polymorphic many-to-many relations, we will change
Expand All @@ -718,8 +779,15 @@ public function morphedByMany($related, $name, $table = null, $foreignPivotKey =
$relatedPivotKey = $relatedPivotKey ?: $name.'_id';

return $this->morphToMany(
$related, $name, $table, $foreignPivotKey,
$relatedPivotKey, $parentKey, $relatedKey, $relation, true
$related,
$name,
$table,
$foreignPivotKey,
$relatedPivotKey,
$parentKey,
$relatedKey,
$relation,
true,
);
}

Expand Down
Loading