Commit 59b96526 authored by Antoine Le Gonidec's avatar Antoine Le Gonidec
Browse files

Switch to astrotomic/laravel-translatable

dimsav/laravel-translatable is no longer maintained,
astrotomic/laravel-translatable is the official continuation
parent 2779d2e2
......@@ -9,7 +9,7 @@
"license": "MIT",
"require": {
"php": ">=7.1.0",
"dimsav/laravel-translatable": "^9.0"
"astrotomic/laravel-translatable": "^11.1"
},
"autoload": {
"psr-4": {
......
......@@ -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
{
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment