From 1a49d9e36a57547cfe1228a96fc79786a96ab095 Mon Sep 17 00:00:00 2001 From: Rayann Nayran Date: Tue, 24 Sep 2019 14:53:48 -0300 Subject: [PATCH] Add support for Laravel 6 All str_ and array_ helpers have been moved to the new laravel/helpers Composer package and removed from the framework. So, I updated all calls to these helpers to use the Illuminate\Support\Str and Illuminate\Support\Arr classes. --- src/EagerLoadPivotBuilder.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/EagerLoadPivotBuilder.php b/src/EagerLoadPivotBuilder.php index e7b7ff8..78c16d4 100644 --- a/src/EagerLoadPivotBuilder.php +++ b/src/EagerLoadPivotBuilder.php @@ -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 { @@ -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)); } @@ -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(