{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/26210","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/26210/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/26210/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/26210/events","html_url":"https://github.com/laravel/framework/issues/26210","id":372342534,"node_id":"MDU6SXNzdWUzNzIzNDI1MzQ=","number":26210,"title":"Modal::find($instance) returning multiple models when passed model instance","user":{"login":"jackcruden","id":2648061,"node_id":"MDQ6VXNlcjI2NDgwNjE=","avatar_url":"https://avatars1.githubusercontent.com/u/2648061?v=4","gravatar_id":"","url":"https://api.github.com/users/jackcruden","html_url":"https://github.com/jackcruden","followers_url":"https://api.github.com/users/jackcruden/followers","following_url":"https://api.github.com/users/jackcruden/following{/other_user}","gists_url":"https://api.github.com/users/jackcruden/gists{/gist_id}","starred_url":"https://api.github.com/users/jackcruden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackcruden/subscriptions","organizations_url":"https://api.github.com/users/jackcruden/orgs","repos_url":"https://api.github.com/users/jackcruden/repos","events_url":"https://api.github.com/users/jackcruden/events{/privacy}","received_events_url":"https://api.github.com/users/jackcruden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-10-21T18:25:17Z","updated_at":"2018-10-25T01:51:14Z","closed_at":null,"author_association":"NONE","body":"- Laravel Version: 5.7.*\r\n- PHP Version: 7.2.10\r\n- Database Driver & Version: MySQL 5.7.17\r\n\r\n### Description:\r\nThis is probably relevant to any Eloquent model, just using User as an example.\r\nWhen using `App\\User::find($user);` where `$user` is a User instance not an ID (or primary key) the User object is treated as an array of IDs (/primary keys) and it's possible for multiple models to be returned given the right data.\r\n\r\nI understand that the data on Emma (in example below) is being treated as IDs, and the `organisation_id` of `1` is picking up Jack. And I know this isn't how `::find()` is intended to be used but shouldn't there be protections in place to stop accidentally passing an instance to the `Model::find()` method?\r\n\r\n### Steps To Reproduce:\r\nAdd the following to the users table:\r\n\r\nid | name | email | organisation_id\r\n--- | --- | --- | ---\r\n1 | jack | jack | 1\r\n2 | emma | emma | 1\r\n\r\nRun the following:\r\n```\r\n// Setup\r\n$emma = App\\User::find(2);\r\n\r\n// To recreate bug\r\nreturn App\\User::find($emma);\r\n\r\n// Result\r\n[Jack instance, Emma instance]\r\n\r\n// Expected result\r\n// Exception or Emma instance?\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/432885615","html_url":"https://github.com/laravel/framework/issues/26210#issuecomment-432885615","issue_url":"https://api.github.com/repos/laravel/framework/issues/26210","id":432885615,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjg4NTYxNQ==","user":{"login":"xuanquynh","id":16967350,"node_id":"MDQ6VXNlcjE2OTY3MzUw","avatar_url":"https://avatars3.githubusercontent.com/u/16967350?v=4","gravatar_id":"","url":"https://api.github.com/users/xuanquynh","html_url":"https://github.com/xuanquynh","followers_url":"https://api.github.com/users/xuanquynh/followers","following_url":"https://api.github.com/users/xuanquynh/following{/other_user}","gists_url":"https://api.github.com/users/xuanquynh/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanquynh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanquynh/subscriptions","organizations_url":"https://api.github.com/users/xuanquynh/orgs","repos_url":"https://api.github.com/users/xuanquynh/repos","events_url":"https://api.github.com/users/xuanquynh/events{/privacy}","received_events_url":"https://api.github.com/users/xuanquynh/received_events","type":"User","site_admin":false},"created_at":"2018-10-25T01:51:14Z","updated_at":"2018-10-25T01:51:14Z","author_association":"CONTRIBUTOR","body":"I know how it behaves and how to change the behavior but this is unnecessary for me. Anyway, Laravel scope is anything that is decided by Mr.Otwell - Laravel author. Let's listen to the other ideas."}}
{"actor":{"display_login":"xuanquynh"}}