added sort save to groups

pull/44/head
A1Gard 6 months ago
parent a265c57277
commit 6c21182f14

@ -137,7 +137,7 @@ class CategoryController extends XController
public function sort(){ public function sort(){
$items = Category::orderBy('sort') $items = Category::orderBy('sort')
->get(['id','name','parent_id']); ->get(['id','name','parent_id']);
return view('admin.categories.category-sort',compact('items')); return view('admin.commons.sort',compact('items'));
} }
public function sortSave(Request $request){ public function sortSave(Request $request){

@ -130,4 +130,24 @@ class GroupController extends XController
return parent::restoreing(Group::withTrashed()->where('id', $item)->first()); return parent::restoreing(Group::withTrashed()->where('id', $item)->first());
} }
/*restore**/ /*restore**/
/**sort*/
public function sort(){
$items = Group::orderBy('sort')
->get(['id','name','parent_id']);
return view('admin.commons.sort',compact('items'));
}
public function sortSave(Request $request){
// return $request->items;
foreach ($request->items as $key => $item){
$i = Group::whereId($item['id'])->first();
$i->sort = $key;
$i->parent_id = $item['parentId']??null;
$i->save();
}
logAdmin(__METHOD__,__CLASS__,null);
return ['OK' => true,'message' => __("As you wished sort saved")];
}
/*sort**/
} }

@ -125,7 +125,6 @@
data-bs-placement="top" data-bs-placement="top"
data-bs-custom-class="custom-tooltip" data-bs-custom-class="custom-tooltip"
data-bs-title="{{__("Save all settings")}}" data-bs-title="{{__("Save all settings")}}"
href="{{getRoute('create')}}"
> >
<i class="ri-save-2-line"></i> <i class="ri-save-2-line"></i>
</button> </button>

@ -7,14 +7,13 @@
<input type="hidden" id="sort-data" > <input type="hidden" id="sort-data" >
<button <button
data-link="{{route('admin.category.sort.save')}}" data-link="{{getRoute('sort-save')}}"
id="save-sort" id="save-sort"
class="action-btn circle-btn" class="action-btn circle-btn"
data-bs-toggle="tooltip" data-bs-toggle="tooltip"
data-bs-placement="top" data-bs-placement="top"
data-bs-custom-class="custom-tooltip" data-bs-custom-class="custom-tooltip"
data-bs-title="{{__("Save")}}" data-bs-title="{{__("Save")}}"
href="{{getRoute('create')}}"
> >
<i class="ri-save-2-line"></i> <i class="ri-save-2-line"></i>
</button> </button>

@ -51,6 +51,8 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::get('restore/{item}', [\App\Http\Controllers\Admin\GroupController::class, 'restore'])->name('restore'); Route::get('restore/{item}', [\App\Http\Controllers\Admin\GroupController::class, 'restore'])->name('restore');
Route::post('bulk', [\App\Http\Controllers\Admin\GroupController::class, "bulk"])->name('bulk'); Route::post('bulk', [\App\Http\Controllers\Admin\GroupController::class, "bulk"])->name('bulk');
Route::get('trashed', [\App\Http\Controllers\Admin\GroupController::class, "trashed"])->name('trashed'); Route::get('trashed', [\App\Http\Controllers\Admin\GroupController::class, "trashed"])->name('trashed');
Route::post('sort/save', [\App\Http\Controllers\Admin\GroupController::class, 'sortSave'])->name('sort-save');
Route::get('sort', [\App\Http\Controllers\Admin\GroupController::class, 'sort'])->name('sort');
}); });
Route::prefix('discounts')->name('discount.')->group( Route::prefix('discounts')->name('discount.')->group(
function () { function () {
@ -129,7 +131,7 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::get('restore/{item}', [\App\Http\Controllers\Admin\CategoryController::class, 'restore'])->name('restore'); Route::get('restore/{item}', [\App\Http\Controllers\Admin\CategoryController::class, 'restore'])->name('restore');
Route::post('bulk', [\App\Http\Controllers\Admin\CategoryController::class, "bulk"])->name('bulk'); Route::post('bulk', [\App\Http\Controllers\Admin\CategoryController::class, "bulk"])->name('bulk');
Route::get('trashed', [\App\Http\Controllers\Admin\CategoryController::class, "trashed"])->name('trashed'); Route::get('trashed', [\App\Http\Controllers\Admin\CategoryController::class, "trashed"])->name('trashed');
Route::post('sort/save', [\App\Http\Controllers\Admin\CategoryController::class, 'sortSave'])->name('sort.save'); Route::post('sort/save', [\App\Http\Controllers\Admin\CategoryController::class, 'sortSave'])->name('sort-save');
Route::get('sort', [\App\Http\Controllers\Admin\CategoryController::class, 'sort'])->name('sort'); Route::get('sort', [\App\Http\Controllers\Admin\CategoryController::class, 'sort'])->name('sort');
}); });
@ -223,7 +225,6 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::get('restore/{item}', [\App\Http\Controllers\Admin\ProductController::class, 'restore'])->name('restore'); Route::get('restore/{item}', [\App\Http\Controllers\Admin\ProductController::class, 'restore'])->name('restore');
Route::post('bulk', [\App\Http\Controllers\Admin\ProductController::class, "bulk"])->name('bulk'); Route::post('bulk', [\App\Http\Controllers\Admin\ProductController::class, "bulk"])->name('bulk');
Route::get('trashed', [\App\Http\Controllers\Admin\ProductController::class, "trashed"])->name('trashed'); Route::get('trashed', [\App\Http\Controllers\Admin\ProductController::class, "trashed"])->name('trashed');
}); });
Route::prefix('props')->name('prop.')->group( Route::prefix('props')->name('prop.')->group(
function () { function () {

Loading…
Cancel
Save