diff --git a/docs/eloquent-models/model-class.txt b/docs/eloquent-models/model-class.txt index 5542b35ea..f1d1fbdda 100644 --- a/docs/eloquent-models/model-class.txt +++ b/docs/eloquent-models/model-class.txt @@ -194,6 +194,24 @@ type, to the Laravel ``datetime`` type. :emphasize-lines: 9-11 :dedent: +.. tip:: Casts in Laravel 11 + + In Laravel 11, you can define a ``casts()`` method to specify data type conversions + instead of using the ``$casts`` attribute. The following code performs the same + conversion as the preceding example by using a ``casts()`` method: + + .. code-block:: php + + protected function casts(): array + { + return [ + 'discovery_dt' => 'datetime', + ]; + } + + To learn more, see `Attribute Casting `__ + in the Laravel documentation. + This conversion lets you use the PHP `DateTime `__ or the `Carbon class `__ to work with dates in this field. The following example shows a Laravel query that uses the