Skip to content

Commit

Permalink
Category delete: complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Slymee committed Jan 4, 2024
1 parent 804dcc1 commit fb288f3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
11 changes: 4 additions & 7 deletions resources/views/backend/admin-category.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@

{{ $mainParent->links() }}
</div>

<script>
function confirmDelete(categoryID, routeURL){
var result = window.confirm('Are you sure you want to delete this category');
if(result){
window.location.href = routeURL+"/"+categoryID+"/destroy";
}
function confirmDelete(categoryId) {
if (confirm('Are you sure you want to delete this category?')) {
window.location.href = '/admin-category/' + categoryId + '/destroy';
}
}
</script>
@endsection
2 changes: 1 addition & 1 deletion resources/views/commonComponents/admin-category.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<td style="text-align: left">
{{ str_repeat('-', $category->level) }} {{ $category->category_name }}</td>
<td><a href={{ route('admin-category.edit', ['admin_category' => $category->id]) }}><button>Edit</button></a></td>
<td><button onclick="confirmDelete({{ $category->id }}, '{{ route('admin-category.index') }}')">Delete</button></td></tr>
<td><button onclick="confirmDelete({{ $category->id }})">Delete</button></td></tr>



Expand Down
3 changes: 2 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
// 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');
Route::resource('admin-category', CategoryController::class);
Route::resource('admin-category', CategoryController::class, ['except' => ['destroy']]);
Route::get('admin-category/{id}/destroy', [CategoryController::class, 'destroy'])->name('admin-category.destroy');
});


Expand Down

0 comments on commit fb288f3

Please sign in to comment.