{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/13629","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/13629/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/13629/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/13629/events","html_url":"https://github.com/laravel/framework/issues/13629","id":155924242,"number":13629,"title":"strange difference between calling findOrFail using an instance object and calling statically","user":{"login":"Enlightments","id":14369451,"avatar_url":"https://avatars.githubusercontent.com/u/14369451?v=3","gravatar_id":"","url":"https://api.github.com/users/Enlightments","html_url":"https://github.com/Enlightments","followers_url":"https://api.github.com/users/Enlightments/followers","following_url":"https://api.github.com/users/Enlightments/following{/other_user}","gists_url":"https://api.github.com/users/Enlightments/gists{/gist_id}","starred_url":"https://api.github.com/users/Enlightments/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Enlightments/subscriptions","organizations_url":"https://api.github.com/users/Enlightments/orgs","repos_url":"https://api.github.com/users/Enlightments/repos","events_url":"https://api.github.com/users/Enlightments/events{/privacy}","received_events_url":"https://api.github.com/users/Enlightments/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-20T09:38:41Z","updated_at":"2016-05-20T17:55:39Z","closed_at":null,"body":"Im developing an application on Laravel framework and i noticed something strange.\r\n\r\nVersion : \r\nLaravel Framework version 5.2.32\r\n\r\nI have a model called \"Level\" and when i call 'findOrFail' statically, it returns a collection of level instances.\r\n\r\n$level = Level::findOrFail($levelId) \r\ndd($level)\r\n\r\nCollection {#360 ▼\r\n  #items: array:1 [▼\r\n    0 => Level {#361 ▶}\r\n     ]\r\n}\r\n\r\nBut when i instantiate an object or use dependency injection, calling 'findOrFail' returns single model object.\r\n\r\n$level = new Level();\r\ndd($level->findOrFail($levelId));\r\n\r\nLevel {#355 ▼\r\n  #table: \"level\"\r\n  #fillable: array:8 [▶]\r\n  #connection: null\r\n  #primaryKey: \"id\"\r\n  #perPage: 15\r\n  +incrementing: true\r\n  +timestamps: true\r\n  #attributes: []\r\n  #original: []\r\n  #relations: []\r\n  #hidden: []\r\n  #visible: []\r\n  #appends: []\r\n  #guarded: array:1 [▶]\r\n  #dates: []\r\n  #dateFormat: null\r\n  #casts: []\r\n  #touches: []\r\n  #observables: []\r\n  #with: []\r\n  #morphClass: null\r\n  +exists: false\r\n  +wasRecentlyCreated: false\r\n}\r\n\r\nI think the existence of `findOrFail` method is to return a single model instance based on a unique primary key so it does not need to return a collection.\r\n\r\nI was wondering if this is a bug or it is supposed to work like this.\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/220675107","html_url":"https://github.com/laravel/framework/issues/13629#issuecomment-220675107","issue_url":"https://api.github.com/repos/laravel/framework/issues/13629","id":220675107,"user":{"login":"Enlightments","id":14369451,"avatar_url":"https://avatars.githubusercontent.com/u/14369451?v=3","gravatar_id":"","url":"https://api.github.com/users/Enlightments","html_url":"https://github.com/Enlightments","followers_url":"https://api.github.com/users/Enlightments/followers","following_url":"https://api.github.com/users/Enlightments/following{/other_user}","gists_url":"https://api.github.com/users/Enlightments/gists{/gist_id}","starred_url":"https://api.github.com/users/Enlightments/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Enlightments/subscriptions","organizations_url":"https://api.github.com/users/Enlightments/orgs","repos_url":"https://api.github.com/users/Enlightments/repos","events_url":"https://api.github.com/users/Enlightments/events{/privacy}","received_events_url":"https://api.github.com/users/Enlightments/received_events","type":"User","site_admin":false},"created_at":"2016-05-20T17:55:38Z","updated_at":"2016-05-20T17:55:38Z","body":"@lagbox \r\nThanks that was the issue.\r\nI was using \"Hashids\" package in order to generate safe query strings and when decoding a SINGLE parameter, it returns an ARRAY with a single value :| \r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"Enlightments"}}