Skip to content

Commit

Permalink
+ Added support for new relation generics
Browse files Browse the repository at this point in the history
  • Loading branch information
tylernathanreed authored Dec 13, 2024
1 parent 358eaa1 commit b1c8bf2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Mixins/RelationJoinQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@

use Closure;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Reedware\LaravelRelationJoins\RelationJoinQuery;

/** @mixin Relation */
/**
* @template TRelatedModel of Model
* @template TDeclaringModel of Model
* @template TResult
*
* @mixin Relation<TRelatedModel,TDeclaringModel,TResult>
*/
class RelationJoinQueries
{
/**
Expand All @@ -17,9 +24,13 @@ public function getRelationJoinQuery(): Closure
{
/**
* Adds the constraints for a relationship join.
*
* @param Builder<TRelatedModel> $query
* @param Builder<TDeclaringModel> $parentQuery
* @return Builder<TRelatedModel>
*/
return function (Builder $query, Builder $parentQuery, string $type = 'inner', ?string $alias = null): Builder {
/** @var Relation $this */
/** @var Relation<TRelatedModel,TDeclaringModel,TResult> $this */
return RelationJoinQuery::get($this, $query, $parentQuery, $type, $alias);
};
}
Expand Down

0 comments on commit b1c8bf2

Please sign in to comment.