From 8b1ee3e219185b0bde8b473028061d9481fc4455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danie=CC=88l=20de=20Wit?= Date: Tue, 17 Sep 2019 16:40:15 +0200 Subject: [PATCH] Add Laravel 6 support Replaced array_ helpers with underlying classes --- composer.json | 2 +- src/QueryDetector.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 6960203..a68a093 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^7.1", - "illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*" + "illuminate/support": "^5.5|^6" }, "require-dev": { "orchestra/testbench": "3.6.*", diff --git a/src/QueryDetector.php b/src/QueryDetector.php index 0e24f99..d9c1863 100755 --- a/src/QueryDetector.php +++ b/src/QueryDetector.php @@ -3,6 +3,7 @@ namespace BeyondCode\QueryDetector; use DB; +use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Database\Eloquent\Builder; use Symfony\Component\HttpFoundation\Response; @@ -47,7 +48,7 @@ public function isEnabled(): bool public function logQuery($query, Collection $backtrace) { $modelTrace = $backtrace->first(function ($trace) { - return array_get($trace, 'object') instanceof Builder; + return Arr::get($trace, 'object') instanceof Builder; }); // The query is coming from an Eloquent model @@ -57,7 +58,7 @@ public function logQuery($query, Collection $backtrace) * or if the class itself is a Relation. */ $relation = $backtrace->first(function ($trace) { - return array_get($trace, 'function') === 'getRelationValue' || array_get($trace, 'class') === Relation::class ; + return Arr::get($trace, 'function') === 'getRelationValue' || Arr::get($trace, 'class') === Relation::class ; }); // We try to access a relation @@ -76,8 +77,8 @@ public function logQuery($query, Collection $backtrace) $key = md5($query->sql . $model . $relationName . $sources[0]->name . $sources[0]->line); - $count = array_get($this->queries, $key.'.count', 0); - $time = array_get($this->queries, $key.'.time', 0); + $count = Arr::get($this->queries, $key.'.count', 0); + $time = Arr::get($this->queries, $key.'.time', 0); $this->queries[$key] = [ 'count' => ++$count,