From 84236282459d964076d55d27e5fd697f60ff6722 Mon Sep 17 00:00:00 2001 From: Crayon Date: Wed, 3 Feb 2021 16:17:49 +0200 Subject: [PATCH] Updated README.md (#84) Added a way to handle translatable models by binding a method to the model. --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 993163b..49944e7 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,17 @@ The following strings are translatable (add then in your language file located i - 'Selected' - 'Press enter to remove' +If you do use nova-translatable and would like to return the translated name add this to your translatable model: +```php + /** + * @return mixed + */ + public function getNameAttribute() + { + return $this->getTranslations('name')[app()->getLocale()]; + } +``` + ## Sample [Demo Project](https://github.com/orlyapps/laravel-nova-demo)