Skip to content

Commit

Permalink
Apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMuller committed Sep 4, 2024
1 parent 8ee6c28 commit 91ccc36
Showing 1 changed file with 7 additions and 36 deletions.
43 changes: 7 additions & 36 deletions src/Relations/BelongsToThrough.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ public function __construct(
parent::__construct($query, $parent);
}

/**
* Set the base constraints on the relation query.
*
* @inheritDoc
*/
/** @inheritDoc */
public function addConstraints()
{
$this->performJoins();
Expand Down Expand Up @@ -179,23 +175,15 @@ public function hasSoftDeletes(Model $model)
return in_array(SoftDeletes::class, class_uses_recursive($model));
}

/**
* Set the constraints for an eager load of the relation.
*
* @inheritDoc
*/
/** @inheritDoc */
public function addEagerConstraints(array $models)
{
$keys = $this->getKeys($models, $this->getFirstForeignKeyName());

$this->query->whereIn($this->getQualifiedFirstLocalKeyName(), $keys);
}

/**
* Initialize the relation on a set of models.
*
* @inheritDoc
*/
/** @inheritDoc */
public function initRelation(array $models, $relation)
{
foreach ($models as $model) {
Expand All @@ -205,11 +193,7 @@ public function initRelation(array $models, $relation)
return $models;
}

/**
* Match the eagerly loaded results to their parents.
*
* @inheritDoc
*/
/** @inheritDoc */
public function match(array $models, Collection $results, $relation)
{
$dictionary = $this->buildDictionary($results);
Expand Down Expand Up @@ -244,12 +228,7 @@ protected function buildDictionary(Collection $results)
return $dictionary;
}

/**
* Get the results of the relationship.
*
* @inheritDoc
* @return TRelatedModel|object|static|null
*/
/** @inheritDoc */
public function getResults()
{
return $this->first() ?: $this->getDefaultFor($this->parent);

Check failure on line 234 in src/Relations/BelongsToThrough.php

View workflow job for this annotation

GitHub Actions / phpstan (8.3, stable)

Method Znck\Eloquent\Relations\BelongsToThrough::getResults() should return TResult but returns object|null.
Expand All @@ -271,11 +250,7 @@ public function first($columns = ['*'])
return $this->query->first($columns);
}

/**
* Execute the query as a "select" statement.
*
* @inheritDoc
*/
/** @inheritDoc */
public function get($columns = ['*'])
{
$columns = $this->query->getQuery()->columns ? [] : $columns;
Expand All @@ -291,11 +266,7 @@ public function get($columns = ['*'])
return $this->query->get();
}

/**
* Add the constraints for a relationship query.
*
* @inheritDoc
*/
/** @inheritDoc */
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
$this->performJoins($query);
Expand Down

0 comments on commit 91ccc36

Please sign in to comment.