Skip to content

Commit 55ffe94

Browse files
authored
Merge pull request #4 from nrayann/master
Add support for Laravel 6
2 parents ff87634 + 1a49d9e commit 55ffe94

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/EagerLoadPivotBuilder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Closure;
66
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
77
use Illuminate\Database\Eloquent\Builder;
8+
use Illuminate\Support\Arr;
9+
use Illuminate\Support\Str;
810

911
class EagerLoadPivotBuilder extends Builder
1012
{
@@ -74,7 +76,7 @@ protected function isPivotAccessor($name)
7476
*/
7577
protected function eagerLoadPivotRelations($models, $pivotAccessor)
7678
{
77-
$pivots = array_pluck($models, $pivotAccessor);
79+
$pivots = Arr::pluck($models, $pivotAccessor);
7880
$pivots = head($pivots)->newCollection($pivots);
7981
$pivots->load($this->getPivotEagerLoadRelations($pivotAccessor));
8082
}
@@ -88,7 +90,7 @@ protected function eagerLoadPivotRelations($models, $pivotAccessor)
8890
protected function getPivotEagerLoadRelations($pivotAccessor)
8991
{
9092
$relations = array_filter($this->eagerLoad, function ($relation) use ($pivotAccessor) {
91-
return $relation != $pivotAccessor && str_contains($relation, $pivotAccessor);
93+
return $relation != $pivotAccessor && Str::contains($relation, $pivotAccessor);
9294
}, ARRAY_FILTER_USE_KEY);
9395

9496
return array_combine(

0 commit comments

Comments
 (0)