Skip to content

Restoring a translatable model tries to insert a new translation for the current locale #440

@vivere-dally

Description

@vivere-dally

Describe the bug
I am trying to restore a model. MyModel::withTrashed()->find(id)->restore().

The saveTransactions method gets called with a translation object for the current locale, with empty attributes. It then tries to insert that into the table, failing.

To Reproduce

class MyModel extends Model implements TranslatableContract
{
    use Translatable;

    public $translatedAttributes = ['name', 'web_name'];
}

Expected behavior
I would expect the restore event to be correctly handled. It is probably handled in the same manner as saved/created events.

Versions (please complete the following information)

  • PHP: 8.1
  • Database: mysql
  • Laravel: 10.16
  • Package: 11.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions