<?php

use App\Http\Controllers\User\SubscriptionController;
use App\Http\Controllers\User\UserContactController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\FrontControllers\FrontController;
use App\Http\Controllers\Admin\CategoryController;
use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\BlogController;
use App\Http\Controllers\Admin\ColourController;
use App\Http\Controllers\Admin\SettingsController as AdminSettingController;
use App\Http\Controllers\Admin\TestimonialController as AdminTestimonialController;
use App\Http\Controllers\Admin\ReviewsController as AdminReviewController;
use App\Http\Controllers\Admin\ContactController as AdminContactController;
use App\Http\Controllers\Admin\FaqController;
use App\Http\Controllers\Admin\GalleryController;
use App\Http\Controllers\Admin\HomePageSliderController;
use App\Http\Controllers\Admin\OurGoalController;
use App\Http\Controllers\Admin\OurTeamController;
use App\Http\Controllers\Admin\PackageController;
use App\Http\Controllers\Admin\UserListingController as AdminUserListingController;
use App\Http\Controllers\Admin\PagesController;
use App\Http\Controllers\Admin\PodcastController;
use App\Http\Controllers\Admin\ProductController;
use App\Http\Controllers\Admin\RecoveryGalleryController;
use App\Http\Controllers\Admin\ServiceController;
use App\Http\Controllers\FrontControllers\AddToCartController;
use App\Http\Controllers\FrontControllers\CheckoutController;
use App\Http\Controllers\FrontControllers\ContactController;
use App\Http\Controllers\FrontControllers\DonationController;
use App\Http\Controllers\User\UserLoginController;
use App\Http\Controllers\User\UserOrderController;
use App\Http\Controllers\User\UserRegisterController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', [FrontController::class, 'index'])->name('front.index');
Route::get('/about', [FrontController::class, 'about'])->name('front.about');
Route::get('/contact', [ContactController::class, 'index'])->name('front.contact');
Route::get('/customer-reviews', [FrontController::class, 'customerReviews'])->name('front.customer.reviews');
Route::get('/customer-service', [FrontController::class, 'customerService'])->name('front.customer.service');
Route::get('/return-policy', [FrontController::class, 'returnPolicy'])->name('front.return.policy');
Route::get('/luxury-candles', [FrontController::class, 'luxuryCandles'])->name('front.luxury.candles');
Route::get('/faq', [FrontController::class, 'faq'])->name('front.faq');
Route::get('/product-detail/{id}', [FrontController::class, 'productDetail'])->name('front.product.detail');
Route::get('/delivery', [FrontController::class, 'delivery'])->name('front.delivery');
Route::post('/contact-sumbit', [ContactController::class, 'submitContactForm'])->name('front.contact.submit');

Route::post('/donation/payment', [DonationController::class, 'store'])->name('front.donation.store');
// Route::post('/payment', [DonationController::class, 'payment'])->name('front.donation.payment');
Route::get('/payment', [DonationController::class, 'paymentFront'])->name('front.payment');
// Route::post('package/success', [SubscriptionController::class, 'packageSubscribe'])->name('front.subscription.store');
Route::get('/success', [SubscriptionController::class, 'success'])->name('front.success');
// Route::get('/cart', [FrontController::class, 'cart'])->name('front.cart');

Route::controller(CheckoutController::class)->group(function () {
    Route::get('checkout', 'index')->name('checkout');
    Route::post('checkout/order', 'checkoutOrder')->name('checkout.order');
    Route::post('payment', 'payment')->name('checkout.payment');
    Route::get('/cancel', 'cancel')->name('cancel');
    Route::get('/thankyou', 'thankYou')->name('thankYou');
});

Route::controller(AddToCartController::class)->group(function () {
    Route::post('cart/add/{id}', 'add')->name('cart.add');
    Route::get('cart/data/load', 'cartDataLoad')->name('cart.data.load');
    Route::get('cart', 'cart')->name('front.cart');
    Route::post('update/to/cart/', 'update')->name('update.to.cart');
    Route::post('delete/to/cart', 'deleteToCart')->name('delete.to.cart');
    // Route::get('get/product-range/{product}/','getProductQty')->name('get.product.qty');
    Route::post('apply/voucher', 'applyVoucher')->name('apply.voucher');
    Route::delete('/cart/remove/{id}','removeFromCart')->name('cart.remove');


});
//  Start admin Route


Route::prefix('admin')->name('admin.')->group(function () {

    Route::middleware(['guest:web'])->group(function () {

        Route::controller(AdminController::class)->group(function () {
            Route::get('login', 'adminLoginView')->name('login-view');
            Route::post('login', 'adminLogin')->name('login');
            Route::get('reset-password', 'showResetLinkView')->name('show-reset-password');
            Route::post('resetlink', 'sentPasswordResetLink')->name('resetlink');
            Route::get('reset-password/{token}', 'showResetUpdateView')->name('show-reset-update-view');
            Route::post('reset-password', 'resetPasswordUpdate')->name('reset-update-password');
        });
    });

    Route::middleware(['auth:web', 'isAdmin'])->group(function () {
        //     Home Setting
        Route::get('setting/create', [AdminSettingController::class, 'settingCreate'])->name('setting.create');
        Route::post('setting/store', [AdminSettingController::class, 'settingStore'])->name('setting.store');


        Route::controller(AdminController::class)->group(function () {

            Route::get('dashboard', 'adminDashboard')->name('dashboard');
            Route::get('logout', 'adminLogout')->name('logout');
            Route::get('change-password', 'adminChangePasswordView')->name('update-password-view');
            Route::get('profile', 'profile')->name('profile');
            Route::post('change-password', 'adminUpdatePassword')->name('update-password');
            Route::post('profile-update', 'adminProfileUpdate')->name('update-profile');
        });


        // Home Page Slider Routes

        Route::controller(HomePageSliderController::class)->group(function () {
            Route::get('home/slider/list', 'index')->name('slider.list');
            Route::get('home/slider/create', 'createPage')->name('slider.create');
            Route::post('home/slider/store', 'store')->name('slider.store');
            Route::get('home/slider/edit/{id}', 'edit')->name('slider.edit');
            Route::post('home/slider/delete', 'delete')->name('slider.delete');
            Route::post('home/slider/{id}', 'update')->name('slider.update');
        });

        // Blogs Routes

        Route::controller(BlogController::class)->group(function () {
            Route::get('blog/list', 'index')->name('blog.list');
            Route::get('blog/create', 'createPage')->name('blog.create');
            Route::post('blog/store', 'store')->name('blog.store');
            Route::get('blog/edit/{id}', 'edit')->name('blog.edit');
            Route::post('blog/delete', 'delete')->name('blog.delete');
            Route::post('blog/{id}', 'update')->name('blog.update');
        });

        // Podcasts Routes

        Route::controller(FaqController::class)->group(function () {
            Route::get('faq/list', 'index')->name('faq.list');
            Route::get('faq/create', 'createPage')->name('faq.create');
            Route::post('faq/store', 'store')->name('faq.store');
            Route::get('faq/edit/{id}', 'edit')->name('faq.edit');
            Route::post('faq/delete', 'delete')->name('faq.delete');
            Route::post('faq/{id}', 'update')->name('faq.update');
        });

         // Colors Routes

         Route::controller(ColourController::class)->group(function () {
            Route::get('colours/list', 'index')->name('colours.list');
            Route::get('colours/create', 'createPage')->name('colour.create');
            Route::post('colours/store', 'store')->name('colour.store');
            Route::get('colours/edit/{id}', 'edit')->name('colour.edit');
            Route::post('colours/delete', 'delete')->name('colour.delete');
            Route::post('colours/{id}', 'update')->name('colour.update');
        });



        //     Category
        Route::controller(CategoryController::class)->group(function () {
            Route::get('category/list', 'index')->name('category.list');
            Route::get('category/create', 'createPage')->name('category.create');
            Route::post('category/store', 'store')->name('category.store');
            Route::get('category/edit/{id}', 'edit')->name('category.edit');
            Route::post('category/update/{id}', 'update')->name('category.update');
            Route::post('category/delete', 'delete')->name('category.delete');
        });


        //     Product
        Route::controller(ProductController::class)->group(function () {
            Route::get('product/list', 'index')->name('product.list');
            Route::get('product/create', 'createPage')->name('product.create');
            Route::post('product/store', 'store')->name('product.store');
            Route::get('product/edit/{id}', 'edit')->name('product.edit');
            Route::post('product/update/{id}', 'update')->name('product.update');
            Route::post('product/delete', 'delete')->name('product.delete');
        });
        //     contact data
        Route::controller(AdminContactController::class)->group(function () {
            Route::get('contact/list', 'contactList')->name('contact.list');
            Route::get('contact/edit/{id}', 'contactEdit')->name('contact.edit');
            Route::post('contact/update/{id}', 'contactUpdate')->name('contact.update');
        });

        // CMS Routes Start
        Route::controller(PagesController::class)->group(function () {
            Route::get('cms/pages/{slug}/edit', 'edit')->name('pages.edit');
            Route::post('cms/pages/{slug}/update', 'editAndUpdate')->name('pages.update');

            Route::get('home/cms-home', 'homePageCMSCreate')->name('home.create');
            Route::post('home/cms-home/store', 'homePageCMStore')->name('home.store');

        });

         // Recovery Gallery  Routes

         Route::controller(GalleryController::class)->group(function () {
            Route::get('gallery/list', 'index')->name('recovery.list');
            Route::get('gallery/create', 'createPage')->name('recovery.create');
            Route::post('gallery/store', 'store')->name('recovery.store');
            Route::get('gallery/edit/{id}', 'edit')->name('recovery.edit');
            Route::post('gallery/delete', 'delete')->name('recovery.delete');
            Route::post('gallery/{id}', 'update')->name('recovery.update');
        });
        // orders

        Route::controller(UserOrderController::class)->group(function () {
            Route::get('order/list', 'orderList')->name('order.list');
            Route::get('order/detail/{id}', 'orderDetail')->name('order.detail');
            Route::post('order/delete', 'delete')->name('order.delete');

        });
        // user listing
        Route::controller(AdminUserListingController::class)->group(function () {
            Route::get('user/list', 'userList')->name('user.list');
            Route::post('/user/{id}/status', 'userStatus')->name('user.status');
        });
    });
});

//  End admin Route

//  Start User Route

Route::prefix('user')->name('user.')->group(function () {

    Route::middleware(['guest:web'])->group(function () {

        Route::controller(UserRegisterController::class)->group(function () {
            Route::get('register', 'userRegisterView')->name('register-view');
            Route::post('register', 'userRegister')->name('register');
            Route::get('verify', 'verify')->name('verify');
            Route::get('reset-password', 'showResetLinkView')->name('show-reset-password');
            Route::post('resetlink', 'sentPasswordResetLink')->name('resetlink');
            Route::get('reset-password/{token}', 'showResetUpdateView')->name('show-reset-update-view');
            Route::post('reset-password', 'resetPasswordUpdate')->name('reset-update-password');
        });

        Route::get('login', [UserLoginController::class, 'userLoginView'])->name('login-view');
        Route::post('login', [UserLoginController::class, 'login'])->name('login');
    });

    Route::middleware(['auth:web', 'isUser'])->group(function () {

        Route::controller(UserLoginController::class)->group(function () {
            Route::get('dashboard', 'userDashboard')->name('dashboard');
            Route::get('logout', 'userLogout')->name('logout');
            Route::get('change-password', 'userChangePasswordView')->name('update-password-view');
            // Route::get('profile', 'profile')->name('profile');
            // Route::post('change-password', 'userUpdatePassword')->name('update-password');
            // Route::post('profile-update', 'userProfileUpdate')->name('update-profile');

        });
        Route::post('user/contact/submit', [UserContactController::class, 'userEmergencyContactSubmit'])->name('emergency.contact.submit');
        // Orders
        Route::controller(UserOrderController::class)->group(function () {
            Route::get('order/list', 'orderList')->name('order.list');
            Route::get('order/detail/{id}', 'orderDetail')->name('order.detail');

        });
    });

});

//  End User Route
