Fix lettura lingue da tradurre

This commit is contained in:
FabioL 2024-03-25 12:32:22 +01:00
parent 935738af86
commit 11e4482d0a
1 changed files with 4 additions and 3 deletions

View File

@ -73,10 +73,11 @@ trait RecordTrait
*/ */
public function save(array $options = []) public function save(array $options = [])
{ {
if ($this->id) { if ($this->id && method_exists($this, 'getTranslatedFields')) {
// Lingue aggiuntive disponibili // Lingue aggiuntive disponibili
$langs = Locale::All()->toArray(); $langs = Locale::All()->pluck('id')->toArray();
$other_langs = array_diff($langs, [Locale::getDefault()->id]); $default_lang = Locale::getDefault();
$other_langs = array_diff($langs, [$default_lang->id]);
// Popolo inizialmente i campi traducibili o allineo quelli uguali // Popolo inizialmente i campi traducibili o allineo quelli uguali
foreach ($this->getTranslatedFields() as $field) { foreach ($this->getTranslatedFields() as $field) {