Skip to content

Commit

Permalink
Support breaking change in Laravel v11.15
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jul 12, 2024
1 parent 979108e commit a70506c
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/Eloquent/Traits/ConcatenatesNativeRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
use Illuminate\Database\Eloquent\Relations\MorphOneOrMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\Relations\Relation;
Expand Down Expand Up @@ -132,6 +133,32 @@ protected function hasOneOrManyDeepFromHasManyThrough(
return [$through, $foreignKeys, $localKeys];
}

/**
* Prepare a has-one-deep or has-many-deep relationship from an existing has-one-through relationship.
*
* @param \Illuminate\Database\Eloquent\Relations\HasOneThrough $relation
* @param \Illuminate\Database\Eloquent\Model[] $through
* @param array $foreignKeys
* @param array $localKeys
* @return array
*/
protected function hasOneOrManyDeepFromHasOneThrough(
HasOneThrough $relation,
array $through,
array $foreignKeys,
array $localKeys
) {
$through[] = get_class($relation->getParent());

$foreignKeys[] = $relation->getFirstKeyName();
$foreignKeys[] = $relation->getForeignKeyName();

$localKeys[] = $relation->getLocalKeyName();
$localKeys[] = $relation->getSecondLocalKeyName();

return [$through, $foreignKeys, $localKeys];
}

/**
* Prepare a has-one-deep or has-many-deep relationship from an existing morph-one or morph-many relationship.
*
Expand Down Expand Up @@ -198,7 +225,8 @@ protected function hasOneOrManyDeepRelationMethod(Relation $relation)
{
$classes = [
BelongsTo::class,
HasManyThrough::class,
HasManyThrough::class, // TODO[L12]
HasOneThrough::class,
MorphOneOrMany::class,
HasOneOrMany::class,
MorphToMany::class,
Expand Down

0 comments on commit a70506c

Please sign in to comment.