Skip to content

Commit

Permalink
Update issues: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Slymee committed Jan 3, 2024
1 parent 6d5f2d9 commit e3af026
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
10 changes: 7 additions & 3 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function edit($category_id)
public function update(CategoryFormValidator $request, Category $category)
{
try{
dd($request->all());
/**
* @Aashish
*
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@section('content')
<div class="form-container">
<span>Edit Category</span>
<form action={{ route('admin.edit.category', ['category_id', $editableData['id']]) }} autocomplete="off" method="POST">
<form action={{ route('admin.edit.category', ['category', $editableData['id']]) }} autocomplete="off" method="POST">
@csrf
<label for="category_name">New Category Name </label><br>
<input type="text" name="category_name" placeholder="Enter New Category Name" value="{{ $editableData['category_name'] }}"><br>
Expand Down
42 changes: 28 additions & 14 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e3af026

Please sign in to comment.