Skip to content

Commit dbb7dfe

Browse files
committed
Merge branch 'main' of https://github.com/mooxphp/moox
2 parents 1ac1398 + cb0ebd5 commit dbb7dfe

6 files changed

Lines changed: 17 additions & 10 deletions

File tree

packages/category/database/migrations/create_categories_table.php.stub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ return new class extends Migration
1818
$table->integer('weight')->nullable();
1919
$table->integer('count')->nullable();
2020
$table->string('color')->nullable();
21+
$table->json('basedata')->nullable();
2122
$table->timestamp('deleted_at')->nullable()->index();
2223
$table->timestamps();
2324
NestedSet::columns($table);

packages/category/src/Moox/Entities/Categories/Category/CategoryResource.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public static function form(Form $form): Form
7878
$rule->where('locale', $locale);
7979
}
8080

81-
return $rule;
8281
},
8382
'table' => 'category_translations',
8483
'column' => 'slug',
@@ -267,7 +266,7 @@ public static function table(Table $table): Table
267266
});
268267
})),
269268
])
270-
->defaultSort('updated_at', 'desc')
269+
->defaultSort('id', 'asc')
271270
->actions([
272271
ViewAction::make(),
273272
EditAction::make()->hidden(fn (): bool => in_array(static::getCurrentTab(), ['trash', 'deleted'])),

packages/core/src/Traits/Taxonomy/HasResourceTaxonomy.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ protected static function createTaxonomyField(string $taxonomy, array $settings,
4141
$modelClass = $taxonomyService->getTaxonomyModel($taxonomy);
4242
$taxonomyService->validateTaxonomy($taxonomy);
4343
$isHierarchical = $settings['hierarchical'] ?? false;
44-
4544
$createFormClass = $settings['createForm'] ?? CoreTaxonomyCreateForm::class;
4645

4746
$commonConfig = [
@@ -55,28 +54,32 @@ protected static function createTaxonomyField(string $taxonomy, array $settings,
5554
]);
5655

5756
if ($validator->fails()) {
57+
5858
return $validator->errors()->first();
5959
}
6060

6161
$model = app($modelClass);
6262

6363
// Check if model is translatable
6464
if (method_exists($model, 'createWithTranslations')) {
65-
$locale = app()->getLocale();
65+
$locale = request()->get('lang') ?? app()->getLocale();
6666
$translations = [
6767
$locale => [
6868
'title' => $data['title'],
6969
'slug' => $data['slug'],
7070
],
7171
];
72+
\Illuminate\Support\Facades\Log::info('translations', $translations);
7273
$newTaxonomy = $model::createWithTranslations([], $translations);
7374
} else {
74-
// Handle non-translatable models
7575
$newTaxonomy = $model::create([
7676
'title' => $data['title'],
7777
'slug' => $data['slug'],
7878
]);
79+
\Illuminate\Support\Facades\Log::info('newTaxonomy', $newTaxonomy);
80+
7981
}
82+
\Illuminate\Support\Facades\Log::info('newTaxonomy', $newTaxonomy);
8083

8184
return $newTaxonomy->id;
8285
},
@@ -89,6 +92,7 @@ protected static function createTaxonomyField(string $taxonomy, array $settings,
8992
titleAttribute: 'title',
9093
parentAttribute: 'parent_id'
9194
)
95+
9296
->enableBranchNode()
9397
->searchable()
9498
->createOptionForm($commonConfig['createOptionForm'])
@@ -105,7 +109,7 @@ protected static function createTaxonomyField(string $taxonomy, array $settings,
105109
->when(method_exists($modelClass, 'whereHas'), function ($query) use ($search) {
106110
$query->whereHas('translations', function ($q) use ($search) {
107111
$q->where('title', 'like', sprintf('%%%s%%', $search))
108-
->where('locale', app()->getLocale());
112+
->where('locale', request()->get('lang') ?? app()->getLocale());
109113
});
110114
}, function ($query) use ($search) {
111115
$query->where('title', 'like', sprintf('%%%s%%', $search));
@@ -135,6 +139,7 @@ public static function getTaxonomyFilters(): array
135139
$taxonomyService = static::getTaxonomyService();
136140
$taxonomies = $taxonomyService->getTaxonomies();
137141
$resourceModel = static::getModel();
142+
138143
$resourceTable = app($resourceModel)->getTable();
139144

140145
return collect($taxonomies)->map(function ($settings, $taxonomy) use ($taxonomyService, $resourceTable): SelectFilter {
@@ -181,6 +186,7 @@ protected static function getTaxonomyColumns(): array
181186
$taxonomyService = static::getTaxonomyService();
182187
$taxonomies = $taxonomyService->getTaxonomies();
183188

189+
184190
return collect($taxonomies)->map(fn ($settings, $taxonomy): TagsColumn => TagsColumn::make($taxonomy)
185191
->label($settings['label'] ?? ucfirst((string) $taxonomy))
186192
->getStateUsing(function ($record) use ($taxonomy, $taxonomyService, $settings) {
@@ -200,7 +206,8 @@ protected static function getTaxonomyColumns(): array
200206
return $query->join('translations', function ($join) use ($modelTable, $modelClass) {
201207
$join->on('translations.translatable_id', '=', $modelTable.'.id')
202208
->where('translations.translatable_type', '=', $modelClass)
203-
->where('translations.locale', '=', app()->getLocale());
209+
->where('translations.locale', '=', request()->get('lang') ?? app()->getLocale());
210+
204211
})->pluck('translations.title');
205212
}, function ($query) use ($modelTable) {
206213
return $query->pluck($modelTable.'.title');

packages/localization/resources/lang/de/localization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
return [
44
'localization' => 'Lokalisierung',
55
'localizations' => 'Lokalisierungen',
6-
6+
'select_language' => 'Sprache auswählen',
77
];

packages/localization/resources/lang/en/localization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
return [
44
'localization' => 'Localization',
55
'localizations' => 'Localizations',
6-
6+
'select_language' => 'Select Language',
77
];

packages/localization/resources/views/lang-selector.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<select onchange="if(this.value) window.location.href = window.location.pathname + '?lang=' + this.value"
22
class="fi-input block w-full rounded-lg border-gray-300 shadow-sm outline-none transition duration-75 focus:border-primary-500 focus:ring-1 focus:ring-inset focus:ring-primary-500 disabled:opacity-70 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-primary-500">
3-
<option value="">Select Language</option>
3+
<option value="">{{ __('localization::localization.select_language') }}</option>
44
@foreach(\Moox\Localization\Models\Localization::all() as $locale)
55
<option value="{{ $locale->language->alpha2 }}" {{ request()->get('lang') == $locale->language->alpha2 ? 'selected' : '' }}>
66
{{ $locale->language->common_name }}

0 commit comments

Comments
 (0)