Skip to content

Commit

Permalink
tidy up the code
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkev committed Jan 5, 2021
1 parent 74a48e2 commit 2527b56
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Relations/BelongsToJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function addConstraints()
if (static::$constraints) {
$table = $this->related->getTable();

$column = is_subclass_of($this->related, \Illuminate\Database\Eloquent\Model::class) ? $table . '.' . $this->ownerKey : $this->ownerKey;
$column = is_subclass_of($this->related, \Illuminate\Database\Eloquent\Model::class) ? $table . '.' . $this->ownerKey : $this->ownerKey;

$this->query->whereIn($column, $this->getForeignKeys());
}
}
Expand All @@ -62,9 +62,9 @@ protected function getEagerModelKeys(array $models)
/**
* Match the eagerly loaded results to their parents.
*
* @param array $models
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param string $relation
* @param string $relation
* @return array
*/
public function match(array $models, Collection $results, $relation)
Expand Down Expand Up @@ -112,7 +112,7 @@ protected function buildDictionary(Collection $results)
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Builder $parentQuery
* @param array|mixed $columns
* @param array|mixed $columns
* @return \Illuminate\Database\Eloquent\Builder
*/
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
Expand All @@ -134,16 +134,16 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Builder $parentQuery
* @param array|mixed $columns
* @param array|mixed $columns
* @return \Illuminate\Database\Eloquent\Builder
*/
public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
{
$query->from($query->getModel()->getTable().' as '.$hash = $this->getRelationCountHash());
$query->from($query->getModel()->getTable() . ' as ' . $hash = $this->getRelationCountHash());

$query->getModel()->setTable($hash);

$ownerKey = $this->relationExistenceQueryOwnerKey($query, $hash.'.'.$this->ownerKey);
$ownerKey = $this->relationExistenceQueryOwnerKey($query, $hash . '.' . $this->ownerKey);

return $query->select($columns)->whereJsonContains(
$this->getQualifiedPath(),
Expand All @@ -155,7 +155,7 @@ public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder
* Get the owner key for the relationship query.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $ownerKey
* @param string $ownerKey
* @return string
*/
protected function relationExistenceQueryOwnerKey(Builder $query, $ownerKey)
Expand Down Expand Up @@ -200,7 +200,7 @@ public function getForeignKeys(Model $model = null)
{
$model = $model ?: $this->child;

$keys = (array) $model->{$this->foreignKey};
$keys = (array)$model->{$this->foreignKey};

return array_filter($keys, function ($key) {
return $key !== null;
Expand Down

0 comments on commit 2527b56

Please sign in to comment.