Skip to content

Commit

Permalink
Merge pull request laravel#1959 from CausaMortis/patch-1
Browse files Browse the repository at this point in the history
disabled_at should be deleted_at
  • Loading branch information
taylorotwell committed Dec 17, 2015
2 parents 8d0f903 + df6dd23 commit b1ba844
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eloquent-mutators.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ You may customize which fields are automatically mutated, and even completely di
*
* @var array
*/
protected $dates = ['created_at', 'updated_at', 'disabled_at'];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
}

When a column is considered a date, you may set its value to a UNIX timestamp, date string (`Y-m-d`), date-time string, and of course a `DateTime` / `Carbon` instance, and the date's value will automatically be correctly stored in your database:

$user = App\User::find(1);

$user->disabled_at = Carbon::now();
$user->deleted_at = Carbon::now();

$user->save();

As noted above, when retrieving attributes that are listed in your `$dates` property, they will automatically be cast to [Carbon](https://github.com/briannesbitt/Carbon) instances, allowing you to use any of Carbon's methods on your attributes:

$user = App\User::find(1);

return $user->disabled_at->getTimestamp();
return $user->deleted_at->getTimestamp();

By default, timestamps are formatted as `'Y-m-d H:i:s'`. If you need to customize the timestamp format, set the `$dateFormat` property on your model. This property determines how date attributes are stored in the database, as well as their format when the model is serialized to an array or JSON:

Expand Down

0 comments on commit b1ba844

Please sign in to comment.