{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/5429","labels_url":"https://api.github.com/repos/laravel/framework/issues/5429/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/5429/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/5429/events","html_url":"https://github.com/laravel/framework/issues/5429","id":40086042,"number":5429,"title":"whereHas() not working with MorphTo()","user":{"login":"nkeena","id":4267904,"avatar_url":"https://avatars.githubusercontent.com/u/4267904?v=3","gravatar_id":"","url":"https://api.github.com/users/nkeena","html_url":"https://github.com/nkeena","followers_url":"https://api.github.com/users/nkeena/followers","following_url":"https://api.github.com/users/nkeena/following{/other_user}","gists_url":"https://api.github.com/users/nkeena/gists{/gist_id}","starred_url":"https://api.github.com/users/nkeena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkeena/subscriptions","organizations_url":"https://api.github.com/users/nkeena/orgs","repos_url":"https://api.github.com/users/nkeena/repos","events_url":"https://api.github.com/users/nkeena/events{/privacy}","received_events_url":"https://api.github.com/users/nkeena/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/laravel/framework/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/laravel/framework/labels/database","name":"database","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-08-12T18:46:35Z","updated_at":"2015-02-03T20:48:00Z","closed_at":null,"body":"The whereHas() method for querying a polymorphic relationship doesn't seem to be working.\r\n\r\nHere are the relationships:\r\n\r\n```php\r\nTransaction.php\r\n\r\npublic function transactionable()\r\n\t{\r\n\t\treturn $this->morphTo('transactionable');\r\n\t}\r\n\r\nReservation.php\r\n\r\npublic function transactions()\r\n    {\r\n        return $this->morphMany('Transaction', 'transactionable');\r\n    }\r\n\r\nProject.php\r\n\r\npublic function transactions()\r\n    {\r\n        return $this->morphMany('Transaction', 'transactionable');\r\n    }\r\n```\r\n\r\n\r\nAnd here is what I am trying to do:\r\n\r\n```php\r\nreturn Transaction::whereHas('transactionable', function($q){\r\n\t\treturn $q->where('id', '=', '1');\r\n\t})->get();\r\n```\r\n\r\nResult:\r\n\r\n```sql\r\nSQLSTATE[42S22]: Column not found: 1054 Unknown column 'transactions.' in 'where clause' (SQL: select * from `transactions` where (select count(*) from `transactions` where `transactions`.`transactionable_id` = `transactions`.`` and `id` = 1) >= 1)\r\n```\r\n\r\nIs this possible?"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/72731338","html_url":"https://github.com/laravel/framework/issues/5429#issuecomment-72731338","issue_url":"https://api.github.com/repos/laravel/framework/issues/5429","id":72731338,"user":{"login":"sgelbart","id":2606884,"avatar_url":"https://avatars.githubusercontent.com/u/2606884?v=3","gravatar_id":"","url":"https://api.github.com/users/sgelbart","html_url":"https://github.com/sgelbart","followers_url":"https://api.github.com/users/sgelbart/followers","following_url":"https://api.github.com/users/sgelbart/following{/other_user}","gists_url":"https://api.github.com/users/sgelbart/gists{/gist_id}","starred_url":"https://api.github.com/users/sgelbart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgelbart/subscriptions","organizations_url":"https://api.github.com/users/sgelbart/orgs","repos_url":"https://api.github.com/users/sgelbart/repos","events_url":"https://api.github.com/users/sgelbart/events{/privacy}","received_events_url":"https://api.github.com/users/sgelbart/received_events","type":"User","site_admin":false},"created_at":"2015-02-03T20:48:00Z","updated_at":"2015-02-03T20:48:00Z","body":"Yup same here. Wonder if this was ever working?"}}