{"action":"opened","issue":{"url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/139","repository_url":"https://api.github.com/repos/jarektkaczyk/eloquence","labels_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/139/labels{/name}","comments_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/139/comments","events_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/139/events","html_url":"https://github.com/jarektkaczyk/eloquence/issues/139","id":189265318,"number":139,"title":"Unexpected behavior in Mappable trait","user":{"login":"jonahgeorge","id":2058205,"avatar_url":"https://avatars.githubusercontent.com/u/2058205?v=3","gravatar_id":"","url":"https://api.github.com/users/jonahgeorge","html_url":"https://github.com/jonahgeorge","followers_url":"https://api.github.com/users/jonahgeorge/followers","following_url":"https://api.github.com/users/jonahgeorge/following{/other_user}","gists_url":"https://api.github.com/users/jonahgeorge/gists{/gist_id}","starred_url":"https://api.github.com/users/jonahgeorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonahgeorge/subscriptions","organizations_url":"https://api.github.com/users/jonahgeorge/orgs","repos_url":"https://api.github.com/users/jonahgeorge/repos","events_url":"https://api.github.com/users/jonahgeorge/events{/privacy}","received_events_url":"https://api.github.com/users/jonahgeorge/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-15T00:25:05Z","updated_at":"2016-11-15T00:25:05Z","closed_at":null,"body":"It seems that the Mappable trait only exposes additional getters/setters for the mapped columns. Is there any intention to make this trait behavior similar to laravel/framework#8200 where the \"bad\" column name is actually removed as a getter/setter?\r\n\r\nExample:\r\n\r\n```\r\nMariaDB> describe cities;\r\n+---------------+------------------+------+-----+---------+----------------+\r\n| Field         | Type             | Null | Key | Default | Extra          |\r\n+---------------+------------------+------+-----+---------+----------------+\r\n| id            | int(11) unsigned | NO   | PRI | NULL    | auto_increment |\r\n| region        | varchar(5)       | NO   |     | NULL    |                |\r\n| region_id     | int(11)          | NO   |     | NULL    |                |\r\n| name          | varchar(100)     | NO   |     | NULL    |                |\r\n\r\nMariaDB> select * from cities;\r\n+----+--------+-----------+-----------------+\r\n| id | region | region_id | name            |\r\n+----+--------+-----------+-----------------+\r\n|  1 | NY     |         1 | New York        |\r\n|  2 | NY     |         1 | Brooklyn        |\r\n\r\nMariaDB> describe regions;\r\n+---------------+------------------+------+-----+---------+----------------+\r\n| Field         | Type             | Null | Key | Default | Extra          |\r\n+---------------+------------------+------+-----+---------+----------------+\r\n| id            | int(11) unsigned | NO   | PRI | NULL    | auto_increment |\r\n| name          | varchar(100)     | NO   |     | NULL    |                |\r\n\r\nMariaDB> select * from regions;\r\n+----+------------------+\r\n| id | name             |\r\n+----+------------------+\r\n|  1 | New York         |\r\n```\r\n\r\n```php\r\nclass City extends Model\r\n{\r\n    use Eloquence, Mappable;\r\n\r\n    public $timestamps = false;\r\n    protected $maps = [\r\n        \"region_name\" => \"region\",\r\n    ];\r\n \r\n    public function region()\r\n    {\r\n        return $this->belongsTo(Region::class);\r\n    }\r\n}\r\n\r\necho City::with('region')->find(1)->toJson();\r\n/*\r\n{\r\n    \"id\": 1,\r\n    \"region\": {\r\n        \"id\": 1,\r\n        \"name\": \"New York\"\r\n    },\r\n    \"region_id\": 1,\r\n    \"name\": \"New York\"\r\n}\r\n*/\r\n\r\necho City::with('region')->find(1)->region; \r\n/*\r\n\"NY\"\r\n*/\r\n```\r\n\r\nThe first example behaves as I would expect; however, in the second example I would expect it to return a class of type Region. Instead it's finding the underlying getter and fetching the region name instead."}}
{"actor":{"display_login":"jonahgeorge"}}