{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/24681","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/24681/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/24681/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/24681/events","html_url":"https://github.com/laravel/framework/pull/24681","id":335747095,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3MzY4MTg2","number":24681,"title":"[5.7] Allow overriding Eloquent model array attribute casting","user":{"login":"robbytaylor","id":2005679,"node_id":"MDQ6VXNlcjIwMDU2Nzk=","avatar_url":"https://avatars1.githubusercontent.com/u/2005679?v=4","gravatar_id":"","url":"https://api.github.com/users/robbytaylor","html_url":"https://github.com/robbytaylor","followers_url":"https://api.github.com/users/robbytaylor/followers","following_url":"https://api.github.com/users/robbytaylor/following{/other_user}","gists_url":"https://api.github.com/users/robbytaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/robbytaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbytaylor/subscriptions","organizations_url":"https://api.github.com/users/robbytaylor/orgs","repos_url":"https://api.github.com/users/robbytaylor/repos","events_url":"https://api.github.com/users/robbytaylor/events{/privacy}","received_events_url":"https://api.github.com/users/robbytaylor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-26T10:04:37Z","updated_at":"2018-06-26T16:51:08Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/24681","html_url":"https://github.com/laravel/framework/pull/24681","diff_url":"https://github.com/laravel/framework/pull/24681.diff","patch_url":"https://github.com/laravel/framework/pull/24681.patch"},"body":"The use case is that libraries exist to extend Eloquent for use with other database drivers, such as MongoDB and ElasticSearch. Some of these (in particular MongoDB) have native support for storing arrays without them needing to be encoded as JSON.\r\n\r\nCurrently, using a MongoDB driver I can't cast an array attribute as such in a model as it results in an error:\r\n\r\n```\r\nErrorException: json_decode() expects parameter 1 to be string, array given\r\n```\r\n\r\nI could overload the fromJson method in the MongoDB Eloquent library, but that doesn't seem entirely right. I don't think a method called fromJson should need to check whether the value is already an array.\r\n\r\nThis would allow Eloquent drivers for database with native array support to override the `fromArray` method to return the value as it is rather than attempting to decode from json.\r\n\r\nAdmittedly, it isn't actually necessary to use a case at all if the database driver natively supports arrays. But this change makes it easier for the database driver to be changed without changing the casts attribute of the model."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/400386363","html_url":"https://github.com/laravel/framework/pull/24681#issuecomment-400386363","issue_url":"https://api.github.com/repos/laravel/framework/issues/24681","id":400386363,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDM4NjM2Mw==","user":{"login":"robbytaylor","id":2005679,"node_id":"MDQ6VXNlcjIwMDU2Nzk=","avatar_url":"https://avatars1.githubusercontent.com/u/2005679?v=4","gravatar_id":"","url":"https://api.github.com/users/robbytaylor","html_url":"https://github.com/robbytaylor","followers_url":"https://api.github.com/users/robbytaylor/followers","following_url":"https://api.github.com/users/robbytaylor/following{/other_user}","gists_url":"https://api.github.com/users/robbytaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/robbytaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbytaylor/subscriptions","organizations_url":"https://api.github.com/users/robbytaylor/orgs","repos_url":"https://api.github.com/users/robbytaylor/repos","events_url":"https://api.github.com/users/robbytaylor/events{/privacy}","received_events_url":"https://api.github.com/users/robbytaylor/received_events","type":"User","site_admin":false},"created_at":"2018-06-26T16:51:08Z","updated_at":"2018-06-26T16:51:08Z","author_association":"NONE","body":"My reasoning was that in the HasAttributes trait it is an alias. I've updated the description which hopefully makes the methods intention clearer. "}}
{"actor":{"display_login":"robbytaylor"}}