Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Regression with auto casting and spatie/laravel-translation #3710

Closed
bastos71 opened this issue May 10, 2021 · 4 comments
Closed

[Bug] Regression with auto casting and spatie/laravel-translation #3710

bastos71 opened this issue May 10, 2021 · 4 comments

Comments

@bastos71
Copy link

Bug report

What I did

Encountered a regression similar to #2880, I could not simply save my translations in database, values where set to null

What I expected to happen

Translations saved in database.

What happened

Translations saved as null

Workaround to fix

Create your own HasTransaltions Trait that overrides getCastsmethod already overrided by Spatie's package, keeping the original one :

<?php
namespace App\Models\Traits;

use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations as BackpackHasTranslations;

trait HasTranslations
{
    use BackpackHasTranslations {
        BackpackHasTranslations::getCasts as traitGetCasts;
    }

    public function getCasts(): array
    {
        return parent::getCasts();
    }
}

Backpack, Laravel, PHP, DB version

### PHP VERSION:
PHP 8.0.3 (cli) (built: Mar  5 2021 07:53:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies
    with Xdebug v3.0.3, Copyright (c) 2002-2021, by Derick Rethans

### LARAVEL VERSION:
v6.20.26@0117d797dc1ab64b1f88d4f6b966380ea7def091

### BACKPACK VERSION:
4.1.43@973e8ab33d42f02272f65e9688ea250fc9502d3d
@tabacitu tabacitu added the Possible Bug A bug that was reported but not confirmed yet. label May 10, 2021
@kenjilabs
Copy link

kenjilabs commented Jul 24, 2021

Hi, I have similar bug, translations are stored in database but they are not showed in the edit page

image

Values are empty
image

Extra field values are there when i do dd($this->crud->getCurrentEntry());
image

Inside the Model

image

It works only if I comment out this section from this file Backpack\CRUD\app\Models\Traits\SpatieTranslatable;

image

@pxpm
Copy link
Contributor

pxpm commented Sep 2, 2021

Hello @kenjilabs

I think your problem is having the column in the casts. The docs says that you are going to make it translatable you should remove it from casts.

I still investigating the other issue, I could not reproduce in L8, I suspect it's a L6 problem.

Best,
Pedro

@pxpm
Copy link
Contributor

pxpm commented Sep 3, 2021

Hello @bastos71

Thanks for the report, but could it be possible that the problem you are having is the same as @kenjilabs ? If not please do as @kenjilabs did and post your model definition and your field definitions.

### PHP VERSION:
PHP 7.4.19 (cli) (built: May  4 2021 14:24:38) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

### LARAVEL VERSION:
v6.20.33@49aa211f2dd1d419bfd9dbbd6f590d57a1dfda58

### BACKPACK VERSION:
4.1.51@756173cf6593c3d530fca0e54831763c796e24d8

I downgraded Laravel to 6 and still could not reproduce your issue.

Let me know if I missed something.

Best,
Pedro

@pxpm pxpm added could not reproduce and removed triage Possible Bug A bug that was reported but not confirmed yet. labels Sep 3, 2021
@pxpm pxpm self-assigned this Sep 3, 2021
@tabacitu
Copy link
Member

tabacitu commented Oct 4, 2021

Hey guys,

Since we couldn't reproduce this and it's got no activity in the past months, I'm going to assume it's a non-issue and close it. @kenjilabs - if I'm mistaken (which I often am) please reply to Pedro's question above so we can reproduce the issue and we'll reopen. Also - sorry for the delayed response, must have slipped through the cracks...

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants