Laravel-Backpack / translation-manager

UI for the admin to quickly translate multi-language Laravel applications.
MIT License
13 stars 1 forks source link

[Bug] Records cannot be edited once saved to the database #14

Closed tringuyenduc2903 closed 3 months ago

tringuyenduc2903 commented 3 months ago

Bug report

What I did

Add a new record -> Edit that record

What I expected to happen

The data was saved successfully after editing

What happened

After editing, old data is still displayed Quay phim màn hình từ 11-04-2024 08:34:16.webm

What I've already tried to fix it

<?php

namespace Backpack\TranslationManager\Models;
    ...
class TranslationLine extends TranslationLineOriginal
{
    ...
    /**
     * Boot the model.
     */
    public static function boot()
    {
    ...
        static::saved(function (TranslationLine $entry): void {
            if (! $entry->database) { // <- What are the conditions???
                $entry = TranslationLineOriginal::create([
                    'group' => $entry->group,
                    'key' => $entry->key,
                    'text' => $entry->text,
                ]);
            }
        });
    ...
    }
}

Context to replicate the bug - Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
8.3.4

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, bcmath, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, igbinary, imagick, imap, intl, ldap, exif, msgpack, mysqli, pcov, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, redis, shmop, SimpleXML, soap, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, memcached, swoole, Zend OPcache, xdebug

### LARAVEL VERSION:
11.3.1.0

### BACKPACK PACKAGE VERSIONS:
backpack/activity-log: 2.0.3
backpack/backupmanager: v5.0.2
backpack/basset: 1.3.0
backpack/crud: 6.7.5
backpack/filemanager: 3.0.7
backpack/generators: v4.0.5
backpack/language-switcher: 2.0.0
backpack/logmanager: v5.0.1
backpack/medialibrary-uploaders: 1.2.0
backpack/permissionmanager: 7.2.0
backpack/pro: 2.1.12
backpack/revise-operation: 2.0.0
backpack/theme-tabler: 1.2.8
backpack/translation-manager: 1.0.1
pxpm commented 3 months ago

Thanks again @tringuyenduc2903 ❤️

I can confirm it was not possible to edit a language line after it's saved into database.

It's fixed in #18

Will tag a new version with the fix in a short time.

Cheers