Skip to content

Add Laravel 6 support ( with helpers changes ) #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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