Skip to content

Commit

Permalink
Merge pull request #4 from nrayann/master
Browse files Browse the repository at this point in the history
Add support for Laravel 6
  • Loading branch information
ajcastro authored Sep 25, 2019
2 parents ff87634 + 1a49d9e commit 55ffe94
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/EagerLoadPivotBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Closure;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

class EagerLoadPivotBuilder extends Builder
{
Expand Down Expand Up @@ -74,7 +76,7 @@ protected function isPivotAccessor($name)
*/
protected function eagerLoadPivotRelations($models, $pivotAccessor)
{
$pivots = array_pluck($models, $pivotAccessor);
$pivots = Arr::pluck($models, $pivotAccessor);
$pivots = head($pivots)->newCollection($pivots);
$pivots->load($this->getPivotEagerLoadRelations($pivotAccessor));
}
Expand All @@ -88,7 +90,7 @@ protected function eagerLoadPivotRelations($models, $pivotAccessor)
protected function getPivotEagerLoadRelations($pivotAccessor)
{
$relations = array_filter($this->eagerLoad, function ($relation) use ($pivotAccessor) {
return $relation != $pivotAccessor && str_contains($relation, $pivotAccessor);
return $relation != $pivotAccessor && Str::contains($relation, $pivotAccessor);
}, ARRAY_FILTER_USE_KEY);

return array_combine(
Expand Down

0 comments on commit 55ffe94

Please # to comment.