From 59b96526ab163611efb00554706f11125c80bf84 Mon Sep 17 00:00:00 2001 From: "Antoine @ Yes We Dev" Date: Fri, 21 Jun 2019 13:47:30 +0200 Subject: [PATCH] Switch to astrotomic/laravel-translatable dimsav/laravel-translatable is no longer maintained, astrotomic/laravel-translatable is the official continuation --- composer.json | 2 +- readme.md | 6 +++--- src/Translatable.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 45b349e..f8f9e69 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "license": "MIT", "require": { "php": ">=7.1.0", - "dimsav/laravel-translatable": "^9.0" + "astrotomic/laravel-translatable": "^11.1" }, "autoload": { "psr-4": { diff --git a/readme.md b/readme.md index 7d5750c..4c2b6a6 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ This package is based on [mrmonat/nova-translatable](https://github.com/mrmonat/nova-translatable). -Adds the ability to show and edit translated fields created with [dimsav/laravel-translatable](https://github.com/dimsav/laravel-translatable) package. +Adds the ability to show and edit translated fields created with [astrotomic/laravel-translatable](https://github.com/Astrotomic/laravel-translatable) package. It will show up in the detail view like this: @@ -30,7 +30,7 @@ Translatable::make('Description'), Make sure, that you have your Eloquent model setup correct: -- First, you need to add the `Dimsav\Translatable\Translatable`-trait. +- First, you need to add the `Astrotomic\Translatable\Translatable`-trait. - Next, you should create a public property `$translatedAttributes` which holds an array with all the names of attributes you wish to make translatable. - Finally, you should make sure that all translatable attributes are set to the `text`-datatype in your database. If your database supports `json`-columns, use that. @@ -38,7 +38,7 @@ Here's an example of a prepared model: ``` php use Illuminate\Database\Eloquent\Model; -use Dimsav\Translatable\Translatable; +use Astrotomic\Translatable\Translatable; class NewsItem extends Model { diff --git a/src/Translatable.php b/src/Translatable.php index 160fb60..bf3ca29 100644 --- a/src/Translatable.php +++ b/src/Translatable.php @@ -48,7 +48,7 @@ class Translatable extends Field $results = []; if ( class_exists('\Spatie\Translatable\TranslatableServiceProvider') && method_exists($resource, 'getTranslations') ) { $results = $resource->getTranslations($attribute); - } elseif ( class_exists('\Dimsav\Translatable\TranslatableServiceProvider') && method_exists($resource, 'translations') ) { + } elseif ( class_exists('\Astrotomic\Translatable\TranslatableServiceProvider') && method_exists($resource, 'translations') ) { $results = $resource->translations->pluck($attribute, config('translatable.locale_key')); } else { $results = data_get($resource, $attribute); @@ -67,7 +67,7 @@ class Translatable extends Field */ protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute) { - if ( class_exists('\Dimsav\Translatable\TranslatableServiceProvider') && method_exists($model, 'translateOrNew') ) { + if ( class_exists('\Astrotomic\Translatable\TranslatableServiceProvider') && method_exists($model, 'translateOrNew') ) { if ( is_array($request[$requestAttribute]) ) { foreach ( $request[$requestAttribute] as $lang => $value ) { $model->translateOrNew($lang)->{$attribute} = $value; -- GitLab