diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index fbbe9e9..8c46607 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -87,6 +87,7 @@ public function edit($category_id) public function update(CategoryFormValidator $request, Category $category) { try{ + dd($request->all()); /** * @Aashish * @@ -110,9 +111,12 @@ public function update(CategoryFormValidator $request, Category $category) * either use update or save. * ---------------fixed------------------- */ - $category->update($request->validated()); - return redirect()->back()->with('message', 'Edit Successful'); - + if($category->update(['category_name' => $request->category_name, + 'parent_id' => $request->parent_id])): + return redirect()->back()->with('message', 'Edit Successful'); + endif; + return redirect()->back()->with('message', 'Edit Failed'); + }catch(\Exception $e){ return redirect()->back()->with('message', $e->getMessage()); } diff --git a/resources/views/backend/modals/admin-edit-category.blade.php b/resources/views/backend/modals/admin-edit-category.blade.php index 336ec18..992efe7 100644 --- a/resources/views/backend/modals/admin-edit-category.blade.php +++ b/resources/views/backend/modals/admin-edit-category.blade.php @@ -15,7 +15,7 @@ @section('content')
Edit Category -
+ @csrf

diff --git a/routes/web.php b/routes/web.php index 2dc7460..eb23679 100644 --- a/routes/web.php +++ b/routes/web.php @@ -32,20 +32,34 @@ //admin dashboard -Route::get('/dashboard', [DashboardController::class, 'index'])->middleware('auth')->name('admin.dashboard'); - -/** - * Instead of writing middleware auth in every routes, Group the route. "Search Route Grouping" - * - * For CRUD operation instead of writing individual routes, use laravel ResourceController " Search ResourceController in laravel " - * - */ -Route::get('/admin-category', [CategoryController::class, 'index'])->middleware('auth')->name('category.and.subcategory'); -Route::get('/admin-category-add', [CategoryController::class, 'show'])->middleware('auth')->name('add.category.form'); -Route::post('/admin-category-add/insert', [CategoryController::class, 'insert'])->middleware('auth')->name('admin.insert.category'); -Route::get('/admin-category-edit/{category_id}', [CategoryController::class, 'edit'])->middleware('auth')->name('admin.edit.category.form'); -Route::post('/admin-category-edit/update/{category_id}', [CategoryController::class, 'update'])->middleware('auth')->name('admin.edit.category'); -Route::get('/admin-delete-category/{category_id}', [CategoryController::class, 'destroy'])->middleware('auth')->name('admin.delete.category'); +// Route::get('/dashboard', [DashboardController::class, 'index'])->middleware('auth')->name('admin.dashboard'); + +// /** +// * Instead of writing middleware auth in every routes, Group the route. "Search Route Grouping" +// * +// * For CRUD operation instead of writing individual routes, use laravel ResourceController " Search ResourceController in laravel " +// * +// */ +// Route::get('/admin-category', [CategoryController::class, 'index'])->middleware('auth')->name('category.and.subcategory'); +// Route::get('/admin-category-add', [CategoryController::class, 'show'])->middleware('auth')->name('add.category.form'); +// Route::post('/admin-category-add/insert', [CategoryController::class, 'insert'])->middleware('auth')->name('admin.insert.category'); +// Route::get('/admin-category-edit/{category_id}', [CategoryController::class, 'edit'])->middleware('auth')->name('admin.edit.category.form'); +// Route::post('/admin-category-edit/update/{category_id}', [CategoryController::class, 'update'])->middleware('auth')->name('admin.edit.category'); +// Route::get('/admin-delete-category/{category_id}', [CategoryController::class, 'destroy'])->middleware('auth')->name('admin.delete.category'); + +Route::middleware(['auth'])->group(function () { + Route::get('/dashboard', [DashboardController::class, 'index'])->name('admin.dashboard'); + Route::get('/admin-category', [CategoryController::class, 'index'])->name('category.and.subcategory'); + Route::get('/admin-category-add', [CategoryController::class, 'show'])->name('add.category.form'); + Route::post('/admin-category-add/insert', [CategoryController::class, 'insert'])->name('admin.insert.category'); + Route::get('/admin-category-edit/{category_id}', [CategoryController::class, 'edit'])->name('admin.edit.category.form'); + Route::post('/admin-category-edit/update/{category_id}', [CategoryController::class, 'update'])->name('admin.edit.category'); + Route::get('/admin-delete-category/{category_id}', [CategoryController::class, 'destroy'])->name('admin.delete.category'); +}); + + + + //Forgot Password Routess