{"action":"opened","issue":{"url":"https://api.github.com/repos/laravel-ardent/ardent/issues/285","labels_url":"https://api.github.com/repos/laravel-ardent/ardent/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/laravel-ardent/ardent/issues/285/comments","events_url":"https://api.github.com/repos/laravel-ardent/ardent/issues/285/events","html_url":"https://github.com/laravel-ardent/ardent/issues/285","id":120581704,"number":285,"title":"belongsTo doesn't find right foreingKey","user":{"login":"lamalab","id":15817529,"avatar_url":"https://avatars.githubusercontent.com/u/15817529?v=3","gravatar_id":"","url":"https://api.github.com/users/lamalab","html_url":"https://github.com/lamalab","followers_url":"https://api.github.com/users/lamalab/followers","following_url":"https://api.github.com/users/lamalab/following{/other_user}","gists_url":"https://api.github.com/users/lamalab/gists{/gist_id}","starred_url":"https://api.github.com/users/lamalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamalab/subscriptions","organizations_url":"https://api.github.com/users/lamalab/orgs","repos_url":"https://api.github.com/users/lamalab/repos","events_url":"https://api.github.com/users/lamalab/events{/privacy}","received_events_url":"https://api.github.com/users/lamalab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-05T19:28:17Z","updated_at":"2015-12-05T19:28:17Z","closed_at":null,"body":"If foreingKey is not specified belongsTo doesn't find the right function to determine it. \r\nin version 3.0.0 this was the code:\r\n```php\r\n$backtrace = debug_backtrace(false);\r\n$caller = ($backtrace[1]['function'] == 'handleRelationalArray')? $backtrace[3] : $backtrace[1];\r\n$relation = $caller['function'];\r\n```\r\nin the latest release (3.2.0) is:\r\n```php\r\nif ($backtrace[1]['function'] == 'handleRelationalArray') {\r\n\t$relation = $backtrace[1]['args'][0];\r\n} else {\r\n\t$relation = $backtrace[3]['function'];\r\n}\r\n```\r\nAs you can see, in 3.2.0 relase $backtrace[1] and backtrace[3] are inverted compared to the version 3.0.0 and this release works well.\r\nInverting $backtrace[1] with $backtrace[3] works well.  \r\nThanks ENx"}}