<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\auth\AuthController;
use App\Http\Controllers\admin\DashboardController;
use App\Http\Controllers\admin\ProductController;
use App\Http\Controllers\admin\CategoryController;
use App\Http\Controllers\admin\Sub_categories;
use App\Http\Controllers\frontend\Frontend;

Route::get('/login', [AuthController::class, 'index'])->name('login');
Route::post('/login', [AuthController::class, 'login'])->name('login.submit');
Route::get('/logout', [AuthController::class, 'logout'])->name('logout');

Route::middleware('auth')->group(function () {
    Route::get('/admin/dashboard', [DashboardController::class, 'index'])->name('admin.dashboard');
    
    // Product Routes
    Route::get('/admin/product', [ProductController::class, 'index'])->name('admin.product');
    Route::get('/admin/product/create', [ProductController::class, 'create'])->name('admin.product.create');
    Route::post('/admin/product/store', [ProductController::class, 'store'])->name('admin.product.store');
    Route::get('/admin/product/edit/{id}', [ProductController::class, 'edit'])->name('admin.product.edit');
    Route::put('/admin/product/update/{id}', [ProductController::class, 'update'])
    ->name('admin.product.update');


    Route::post('/admin/product/delete/{id}', [ProductController::class, 'destroy'])->name('admin.product.delete');

    // Category Routes
    Route::get('/admin/category', [CategoryController::class, 'index'])->name('admin.category');
    Route::get('/admin/category/create', [CategoryController::class, 'create'])->name('admin.category.create');
    Route::post('/admin/category/store', [CategoryController::class, 'store'])->name('admin.category.store');
    Route::get('/admin/category/edit/{id}', [CategoryController::class, 'edit'])->name('admin.category.edit');
    Route::post('/admin/category/update/{id}', [CategoryController::class, 'update'])->name('admin.category.update');
    Route::get('/admin/category/delete/{id}', [CategoryController::class, 'destroy'])->name('admin.category.delete');

    Route::get('/admin/sub_category', [Sub_categories::class, 'index'])->name('admin.sub_category');
    Route::get('/admin/sub_category/create', [Sub_categories::class, 'create'])->name('admin.sub_category.create');
    Route::post('/admin/sub_category/store', [Sub_categories::class, 'store'])->name('admin.sub_category.store');




    // Route::post('/admin/category/', [CategoryController::class, 'store'])->name('admin.category.store');
});


Route::get('/', [Frontend::class, 'index'])->name('index'); 
Route::get('/about', [Frontend::class, 'about'])->name('about'); 
Route::get('/shop', [Frontend::class, 'shop'])->name('shop'); 
Route::get('/category', [Frontend::class, 'category'])->name('category'); 
Route::get('/cart', [Frontend::class, 'cart'])->name('cart'); 
Route::get('/checkout', [Frontend::class, 'checkout'])->name('checkout'); 