formatting

This commit is contained in:
Taylor Otwell 2018-04-30 10:28:25 -07:00
parent b38edf6027
commit 7f826ecf5f
1 changed files with 14 additions and 0 deletions

View File

@ -220,3 +220,17 @@ Once the cast is defined, you may access the `options` attribute and it will aut
$user->options = $options;
$user->save();
<a name="date-casting"></a>
### Date Casting
When using the `date` or `datetime` cast type, you may specify the date's format. This format will be used when the [model is serialized to an array or JSON](/docs/{{version}}/eloquent-serialization):
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'created_at' => 'datetime:Y-m-d',
];