Skip to content

Commit

Permalink
Merge pull request #55 from daniel-de-wit/master
Browse files Browse the repository at this point in the history
Add Laravel 6 support ( with helpers changes )
  • Loading branch information
mpociot authored Sep 18, 2019
2 parents d46af6b + 8b1ee3e commit 12ca2c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand Down
9 changes: 5 additions & 4 deletions src/QueryDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 12ca2c9

Please sign in to comment.