v1.2.2
- Subcategories can now be reordered within their category — up/down arrow buttons next to "Edytuj" in Admin > Kategorie. The order set there is used everywhere a subcategory list is shown (pickers, admin listings, etc.).
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('subcategories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('sort_order')->default(0)->after('default_priority_key');
|
||||
});
|
||||
|
||||
foreach (DB::table('subcategories')->orderBy('category_id')->orderBy('id')->get() as $position => $sub) {
|
||||
DB::table('subcategories')->where('id', $sub->id)->update(['sort_order' => $position]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('subcategories', function (Blueprint $table) {
|
||||
$table->dropColumn('sort_order');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user