Skip to content

Commit

Permalink
Update with master
Browse files Browse the repository at this point in the history
  • Loading branch information
jyrkidn committed Sep 3, 2024
2 parents c8e9986 + a68e984 commit 6bcaba5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.2.0 - 2024-08-30

### What's Changed

* Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/codedor/filament-media-library/pull/38
* Upgrade to translatable tabs v1.2.0 by @jyrkidn in https://github.com/codedor/filament-media-library/pull/41

**Full Changelog**: https://github.com/codedor/filament-media-library/compare/v1.1.1...v1.2.0

## v1.1.1 - 2024-07-04

### What's Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"php": "^8.2|^8.3",
"blade-ui-kit/blade-icons": "^1.5",
"codedor/filament-resource-picker": "^1.0",
"codedor/filament-translatable-tabs": "^1.0",
"codedor/filament-translatable-tabs": "^1.2",
"filament/filament": "^3.0",
"illuminate/contracts": "^10.0|^11.0",
"livewire/livewire": "^3.0",
Expand Down
21 changes: 17 additions & 4 deletions src/Filament/Actions/Traits/CanUploadAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Codedor\MediaLibrary\Models\Attachment;
use Codedor\MediaLibrary\Models\AttachmentTag;
use Codedor\TranslatableTabs\Forms\TranslatableTabs;
use Codedor\TranslatableTabs\Resources\Traits\HasTranslations;
use Filament\Forms\Components\Component;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Placeholder;
Expand All @@ -22,8 +21,6 @@

trait CanUploadAttachment
{
use HasTranslations;

protected bool|Closure $multiple = false;

protected function setUp(): void
Expand Down Expand Up @@ -52,7 +49,7 @@ protected function setUp(): void
return $attachmentId;
}

$attachment->update($this->mutateFormDataBeforeSave($meta));
$attachment->update($this->mutateData($meta));

if (array_key_exists('tags', $meta)) {
$attachment->tags()->sync($meta['tags']);
Expand Down Expand Up @@ -168,4 +165,20 @@ protected function getAttachmentInformationStep(): Step
->toArray();
});
}

protected function mutateData(array $data): array
{
$model = app($this->getModel());
foreach (Arr::except($data, $model->getFillable()) as $locale => $values) {
if (! is_array($values)) {
continue;
}

foreach (Arr::only($values, $model->getTranslatableAttributes()) as $key => $value) {
$data[$key][$locale] = $value;
}
}

return $data;
}
}

0 comments on commit 6bcaba5

Please sign in to comment.