{"action":"created","issue":{"url":"https://api.github.com/repos/beyondcode/laravel-query-detector/issues/12","repository_url":"https://api.github.com/repos/beyondcode/laravel-query-detector","labels_url":"https://api.github.com/repos/beyondcode/laravel-query-detector/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/beyondcode/laravel-query-detector/issues/12/comments","events_url":"https://api.github.com/repos/beyondcode/laravel-query-detector/issues/12/events","html_url":"https://github.com/beyondcode/laravel-query-detector/issues/12","id":342343649,"node_id":"MDU6SXNzdWUzNDIzNDM2NDk=","number":12,"title":"Undefined index: object","user":{"login":"JackWH","id":627533,"node_id":"MDQ6VXNlcjYyNzUzMw==","avatar_url":"https://avatars2.githubusercontent.com/u/627533?v=4","gravatar_id":"","url":"https://api.github.com/users/JackWH","html_url":"https://github.com/JackWH","followers_url":"https://api.github.com/users/JackWH/followers","following_url":"https://api.github.com/users/JackWH/following{/other_user}","gists_url":"https://api.github.com/users/JackWH/gists{/gist_id}","starred_url":"https://api.github.com/users/JackWH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JackWH/subscriptions","organizations_url":"https://api.github.com/users/JackWH/orgs","repos_url":"https://api.github.com/users/JackWH/repos","events_url":"https://api.github.com/users/JackWH/events{/privacy}","received_events_url":"https://api.github.com/users/JackWH/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-18T14:05:17Z","updated_at":"2018-07-18T14:40:11Z","closed_at":"2018-07-18T14:15:40Z","author_association":"NONE","body":"Hi,\r\n\r\nWhen I try and load my application since installing this, I'm getting \"Undefined index: object\" on just about every page load.\r\n\r\nThis error is being triggered by `/home/vagrant/sites/mysite/vendor/beyondcode/laravel-query-detector/src/QueryDetector.php` on line `60`.\r\n\r\nAs a test, I did `dd($relation)` just before line 60. The output of the dump is below — as you can see there's no `object` index. Not sure if this is caused by a quirk in my application, or something in the package?\r\n\r\n```\r\narray:6 [\r\n  \"file\" => \"/home/vagrant/sites/mysite/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php\"\r\n  \"line\" => 550\r\n  \"function\" => \"noConstraints\"\r\n  \"class\" => \"Illuminate\\Database\\Eloquent\\Relations\\Relation\"\r\n  \"type\" => \"::\"\r\n  \"args\" => array:1 [...]\r\n]\r\n```\r\n\r\nThanks in advance,\r\n\r\nJack"},"comment":{"url":"https://api.github.com/repos/beyondcode/laravel-query-detector/issues/comments/405954952","html_url":"https://github.com/beyondcode/laravel-query-detector/issues/12#issuecomment-405954952","issue_url":"https://api.github.com/repos/beyondcode/laravel-query-detector/issues/12","id":405954952,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTk1NDk1Mg==","user":{"login":"JackWH","id":627533,"node_id":"MDQ6VXNlcjYyNzUzMw==","avatar_url":"https://avatars2.githubusercontent.com/u/627533?v=4","gravatar_id":"","url":"https://api.github.com/users/JackWH","html_url":"https://github.com/JackWH","followers_url":"https://api.github.com/users/JackWH/followers","following_url":"https://api.github.com/users/JackWH/following{/other_user}","gists_url":"https://api.github.com/users/JackWH/gists{/gist_id}","starred_url":"https://api.github.com/users/JackWH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JackWH/subscriptions","organizations_url":"https://api.github.com/users/JackWH/orgs","repos_url":"https://api.github.com/users/JackWH/repos","events_url":"https://api.github.com/users/JackWH/events{/privacy}","received_events_url":"https://api.github.com/users/JackWH/received_events","type":"User","site_admin":false},"created_at":"2018-07-18T14:40:11Z","updated_at":"2018-07-18T14:40:11Z","author_association":"NONE","body":"I'm struggling a bit to pin it down as to where in the application in causing this. Looking at the debug backtrace, the last bit of my application code that triggers before this errors is contained within an Eloquent global scope class, that runs on every page load and is assigned to multiple models. Here's the relevant code within the class:\r\n\r\n```\r\n// Try to get the user via their native session\r\nif (! $this->user) {\r\n    $this->user = auth()->user();\r\n}\r\n```\r\n\r\nSpecifically the call to `auth()->user();` seems to hand everything else over to Laravel behind the scenes, before the query detector takes over and errors.\r\n\r\nIn fact, if I just try and call `$test = \\Auth::user();` right at the top of this global scope class, query detector fails immediately before it gets to any of the logic within the rest of the class. \r\n\r\nI'm not sure if it's something weird with having a global scope being applied to every model load?"}}
{"actor":{"display_login":"JackWH"}}