Skip to content

Commit 287da83

Browse files
AzGasimgithub-actions[bot]
authored andcommitted
Fix styling
1 parent b2f02b0 commit 287da83

File tree

3 files changed

+47
-49
lines changed

3 files changed

+47
-49
lines changed

packages/media/src/Models/Media.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
namespace Moox\Media\Models;
44

5+
use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract;
6+
use Astrotomic\Translatable\Translatable;
57
use Exception;
6-
use Spatie\Image\Enums\Fit;
7-
use Spatie\MediaLibrary\HasMedia;
8+
use Illuminate\Database\Eloquent\Relations\MorphTo;
89
use Illuminate\Support\Facades\DB;
9-
use Moox\Media\Traits\HasMediaUsable;
10-
use Astrotomic\Translatable\Translatable;
1110
use Moox\Localization\Models\Localization;
11+
use Moox\Media\Traits\HasMediaUsable;
12+
use Spatie\Image\Enums\Fit;
13+
use Spatie\MediaLibrary\HasMedia;
1214
use Spatie\MediaLibrary\InteractsWithMedia;
13-
use Illuminate\Database\Eloquent\Relations\MorphTo;
1415
use Spatie\MediaLibrary\MediaCollections\Models\Media as BaseMedia;
15-
use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract;
1616

1717
class Media extends BaseMedia implements HasMedia, TranslatableContract
1818
{
@@ -155,28 +155,28 @@ protected static function booted()
155155
} else {
156156
$collectionChanged = true;
157157
}
158-
159-
if (!$media->exists || $collectionChanged || empty($media->collection_name)) {
158+
159+
if (! $media->exists || $collectionChanged || empty($media->collection_name)) {
160160
$collection = MediaCollection::with('translations')->find($media->media_collection_id);
161-
161+
162162
if ($collection) {
163163
$defaultLocale = config('app.locale');
164-
164+
165165
if (class_exists(Localization::class)) {
166166
$localization = Localization::where('is_default', true)
167167
->where('is_active_admin', true)
168168
->with('language')
169169
->first();
170-
170+
171171
if ($localization && $localization->language) {
172172
$defaultLocale = $localization->locale_variant ?: $localization->language->alpha2;
173173
}
174174
}
175-
175+
176176
$translation = $collection->translations->firstWhere('locale', $defaultLocale);
177177
$newCollectionName = null;
178-
179-
if ($translation && !empty($translation->name)) {
178+
179+
if ($translation && ! empty($translation->name)) {
180180
$newCollectionName = $translation->name;
181181
} else {
182182
if ($collection->translations->isNotEmpty()) {
@@ -185,15 +185,15 @@ protected static function booted()
185185
$newCollectionName = $collection->name ?? null;
186186
}
187187
}
188-
189-
if ($collectionChanged || !empty($newCollectionName)) {
188+
189+
if ($collectionChanged || ! empty($newCollectionName)) {
190190
$media->collection_name = $newCollectionName;
191191
}
192192
} else {
193193
$media->collection_name = null;
194194
}
195195
}
196-
} elseif ($media->isDirty('media_collection_id') && !$media->media_collection_id) {
196+
} elseif ($media->isDirty('media_collection_id') && ! $media->media_collection_id) {
197197
$media->collection_name = null;
198198
}
199199
});

packages/media/src/Resources/MediaResource.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -338,49 +338,48 @@ public static function form(Schema $schema): Schema
338338
->disabled(fn ($record) => $record?->getOriginal('write_protected'))
339339
->options(function ($record, $livewire) {
340340
$currentLang = $livewire->lang ?? app()->getLocale();
341-
341+
342342
$collections = MediaCollection::query()
343343
->with('translations')
344344
->get();
345-
345+
346346
$options = [];
347347
foreach ($collections as $collection) {
348348
$name = null;
349-
349+
350350
$translation = $collection->translations()->where('locale', $currentLang)->first();
351-
352-
if ($translation && !empty($translation->name)) {
351+
352+
if ($translation && ! empty($translation->name)) {
353353
$name = $translation->name;
354354
} else {
355355
if (class_exists(\Moox\Localization\Models\Localization::class)) {
356356
$defaultLocale = optional(\Moox\Localization\Models\Localization::where('is_default', true)
357357
->first()?->language)->alpha2 ?? config('app.locale');
358-
358+
359359
$translation = $collection->translations()->where('locale', $defaultLocale)->first();
360-
if ($translation && !empty($translation->name)) {
360+
if ($translation && ! empty($translation->name)) {
361361
$name = $translation->name;
362362
}
363363
}
364-
364+
365365
if (empty($name)) {
366366
$anyTranslation = $collection->translations()->whereNotNull('name')->first();
367-
$name = $anyTranslation?->name ?? 'Collection #' . $collection->id;
367+
$name = $anyTranslation?->name ?? 'Collection #'.$collection->id;
368368
}
369369
}
370-
370+
371371
$options[$collection->id] = $name;
372372
}
373-
373+
374374
return $options;
375375
})
376376
->default(fn ($record) => $record->media_collection_id)
377377
->afterStateUpdated(function ($state, $record) {
378378
if ($state !== $record->media_collection_id) {
379379
$record->media_collection_id = $state;
380-
381-
380+
382381
$record->collection_name = null;
383-
382+
384383
$record->save();
385384
}
386385
}),

packages/media/src/Resources/MediaResource/Pages/ListMedia.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Filament\Forms\Components\Select;
88
use Filament\Notifications\Notification;
99
use Moox\Core\Entities\Items\Draft\Pages\BaseListDrafts;
10-
use Moox\Data\Models\StaticLanguage;
1110
use Moox\Localization\Models\Localization;
1211
use Moox\Media\Models\Media;
1312
use Moox\Media\Models\MediaCollection;
@@ -129,47 +128,47 @@ public function getHeaderActions(): array
129128
->label(__('media::fields.collection'))
130129
->options(function () {
131130
$currentLang = $this->lang ?? app()->getLocale();
132-
131+
133132
$collections = MediaCollection::query()
134133
->with('translations')
135134
->get();
136-
135+
137136
$options = [];
138137
foreach ($collections as $collection) {
139138
$translation = $collection->translations()->where('locale', $currentLang)->first();
140-
141-
if ($translation && !empty($translation->name)) {
139+
140+
if ($translation && ! empty($translation->name)) {
142141
$name = $translation->name;
143142
} else {
144143
if (class_exists(Localization::class)) {
145144
$defaultLocale = Localization::where('is_default', true)
146145
->where('is_active_admin', true)
147146
->with('language')
148147
->first();
149-
148+
150149
if ($defaultLocale && $defaultLocale->language) {
151150
$defaultLang = $defaultLocale->locale_variant ?: $defaultLocale->language->alpha2;
152151
$fallbackTranslation = $collection->translations()->where('locale', $defaultLang)->first();
153-
if ($fallbackTranslation && !empty($fallbackTranslation->name)) {
152+
if ($fallbackTranslation && ! empty($fallbackTranslation->name)) {
154153
$name = $fallbackTranslation->name;
155154
}
156155
}
157156
}
158-
157+
159158
if (empty($name)) {
160159
$anyTranslation = $collection->translations()->whereNotNull('name')->first();
161160
$name = $anyTranslation?->name;
162161
}
163-
162+
164163
if (empty($name)) {
165164
$name = __('media::fields.uncategorized');
166165
}
167166
}
168-
167+
169168
$options[$collection->id] = trim((string) $name);
170169
}
171-
172-
return array_filter($options, fn($value) => !empty($value));
170+
171+
return array_filter($options, fn ($value) => ! empty($value));
173172
})
174173
->default(MediaCollection::first()?->id)
175174
->searchable()
@@ -209,23 +208,23 @@ public function getHeaderActions(): array
209208

210209
$collectionId = $get('media_collection_id');
211210
$collection = MediaCollection::with('translations')->find($collectionId);
212-
211+
213212
$collectionName = __('media::fields.uncategorized');
214213
if ($collection) {
215214
$defaultLang = config('app.locale');
216-
215+
217216
$localization = Localization::where('is_default', true)
218217
->where('is_active_admin', true)
219218
->with('language')
220219
->first();
221-
220+
222221
if ($localization && $localization->language) {
223222
$defaultLang = $localization->locale_variant ?: $localization->language->alpha2;
224223
}
225-
224+
226225
$translation = $collection->translations->firstWhere('locale', $defaultLang);
227-
228-
if ($translation && !empty($translation->name)) {
226+
227+
if ($translation && ! empty($translation->name)) {
229228
$collectionName = $translation->name;
230229
} elseif ($collection->translations->isNotEmpty()) {
231230
$collectionName = $collection->translations->first()->name;

0 commit comments

Comments
 (0)