Skip to content

Commit

Permalink
Add support for Collection::whereInstanceof()
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiCollin committed Mar 7, 2018
1 parent e3cb69d commit 673c045
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/AnalogueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function register()

// If the cache is pre laravel 5.5, it doesn't implements PSR-16, so we'll skip it.
$cache = $app->make(CacheRepository::class);

if ($cache instanceof CacheInterface) {
$manager->setCache($cache);
}
Expand Down
10 changes: 10 additions & 0 deletions src/System/Proxies/CollectionProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ public function where($key, $operator, $value = null)

return $parent->where($key, $operator, $value);
}

/**
* {@inheritdoc}
*/
public function whereInstanceOf($type)
{
$this->initializeProxy();

return parent::whereInstanceOf($type);
}

/**
* {@inheritdoc}
Expand Down
6 changes: 1 addition & 5 deletions src/System/Wrappers/ObjectWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,7 @@ protected function relationNeedsProxy($relation, $attributes)
$localKey = $localKey['id'];
}

if (!isset($attributes[$localKey])) {
return false;
}

if (is_null($attributes[$localKey])) {
if (!isset($attributes[$localKey]) || is_null($attributes[$localKey]) ) {
return false;
}

Expand Down

0 comments on commit 673c045

Please sign in to comment.