{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/9276","labels_url":"https://api.github.com/repos/laravel/framework/issues/9276/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/9276/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/9276/events","html_url":"https://github.com/laravel/framework/issues/9276","id":88391376,"number":9276,"title":"Improving mutator cache in Eloquent","user":{"login":"reshadman","id":5187816,"avatar_url":"https://avatars.githubusercontent.com/u/5187816?v=3","gravatar_id":"","url":"https://api.github.com/users/reshadman","html_url":"https://github.com/reshadman","followers_url":"https://api.github.com/users/reshadman/followers","following_url":"https://api.github.com/users/reshadman/following{/other_user}","gists_url":"https://api.github.com/users/reshadman/gists{/gist_id}","starred_url":"https://api.github.com/users/reshadman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reshadman/subscriptions","organizations_url":"https://api.github.com/users/reshadman/orgs","repos_url":"https://api.github.com/users/reshadman/repos","events_url":"https://api.github.com/users/reshadman/events{/privacy}","received_events_url":"https://api.github.com/users/reshadman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-15T11:06:47Z","updated_at":"2015-06-15T11:24:25Z","closed_at":"2015-06-15T11:15:04Z","body":"Currently the eloquent model class contains a cache strategy for getters which first fetches all class methods and runs a loop on them filtering them by a regular expression.  \r\nThis occurs [only once](https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Model.php#L3207) per unique eloquent final object.  \r\nThe getter cache container is only filled up with the [processed snake case attribute key](https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Model.php#L3238).\r\n\r\nEach time a new model class is created for first time a loop with 50 to 100 iterations with processing a regular expression is run. \r\n\r\nWouldn't it be cool to have something like ```php artisan eloquent:cache``` for this ?\r\n\r\nAlso the method name can be saved in the mutator cache container, which prevents further string processing (for fetching method name from a given attribute) as both *attribute* name and the *getter method name* exist in the cache array.\r\n\r\n```php\r\n$mutatedAttributes[$method] = lcfirst($matches[1]);\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/112023792","html_url":"https://github.com/laravel/framework/issues/9276#issuecomment-112023792","issue_url":"https://api.github.com/repos/laravel/framework/issues/9276","id":112023792,"user":{"login":"reshadman","id":5187816,"avatar_url":"https://avatars.githubusercontent.com/u/5187816?v=3","gravatar_id":"","url":"https://api.github.com/users/reshadman","html_url":"https://github.com/reshadman","followers_url":"https://api.github.com/users/reshadman/followers","following_url":"https://api.github.com/users/reshadman/following{/other_user}","gists_url":"https://api.github.com/users/reshadman/gists{/gist_id}","starred_url":"https://api.github.com/users/reshadman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reshadman/subscriptions","organizations_url":"https://api.github.com/users/reshadman/orgs","repos_url":"https://api.github.com/users/reshadman/repos","events_url":"https://api.github.com/users/reshadman/events{/privacy}","received_events_url":"https://api.github.com/users/reshadman/received_events","type":"User","site_admin":false},"created_at":"2015-06-15T11:24:25Z","updated_at":"2015-06-15T11:24:25Z","body":"It does not have bold impact but it is not minimal, usually for me eloquent models contain more than 50 (without parents).\r\n\r\nat least, I think storing the method name in the cache array wouldn't be a pain, as it will prevent calling extra ```snake_case``` calls."}}