laravel/framework — pull request #4948 by daylerees (2014-07-02 21:56:30+00:00)
Title: Allow for Eloquent model attributes to be type juggled (casted).

Right now if you retrieve an attribute from an Eloquent model, it may not be in the right format. For example, a `boolean` value in the database will be returned as an `integer` because Eloquent has no knowledge about the table schema.

This PR solves this problem by providing the `$cast` array where you can specify default set/get attribute types for Eloquent model attributes. Here's an example.

```php
'string',
'read' => 'bool',
'read_when' => 'date',
'price' => 'double'
];
}
```

Now all of the attributes provided as keys in the above array, are set and retrieved in the appropriate type. As you can see, dates have been added to this `$cast` array as a replacement for `$dates` due to their similarity. This change has been made backwards compatible, and will respect the original `$dates` array to allow for hotfix.