Skip to content

Commit 8438133

Browse files
authored
Merge pull request #4679 from barryvdh/patch-13
[5.7] Add `decimal` to cast docs
2 parents 6104126 + 9469bb6 commit 8438133

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

eloquent-mutators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ By default, timestamps are formatted as `'Y-m-d H:i:s'`. If you need to customiz
158158
<a name="attribute-casting"></a>
159159
## Attribute Casting
160160

161-
The `$casts` property on your model provides a convenient method of converting attributes to common data types. The `$casts` property should be an array where the key is the name of the attribute being cast and the value is the type you wish to cast the column to. The supported cast types are: `integer`, `real`, `float`, `double`, `string`, `boolean`, `object`, `array`, `collection`, `date`, `datetime`, and `timestamp`.
161+
The `$casts` property on your model provides a convenient method of converting attributes to common data types. The `$casts` property should be an array where the key is the name of the attribute being cast and the value is the type you wish to cast the column to. The supported cast types are: `integer`, `real`, `float`, `double`, `decimal:<digits>`, `string`, `boolean`, `object`, `array`, `collection`, `date`, `datetime`, and `timestamp`. When casting to `decimal`, you should define the number of digits, eg. `decimal:2`
162162

163163
For example, let's cast the `is_admin` attribute, which is stored in our database as an integer (`0` or `1`) to a boolean value:
164164

0 commit comments

Comments
 (0)