<?php

use App\Http\Controllers\Web\PageController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\Login\AdminLoginController;
use App\Http\Controllers\Web\UserLoginController;
use App\Http\Controllers\Admin\HomeController;
use App\Http\Controllers\PaymentController;

/*
|--------------------------------------------------------------------------
| 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('auth', [AdminLoginController::class, 'admin_login'])->name('admin_login');

Route::post('admin-login-check', [AdminLoginController::class, 'admin_login_check'])->name('admin_login_check');

Route::get('/', [PageController::class, 'index'])->name('home');

Route::get('about', [PageController::class, 'aboutPage'])->name('about_page');
Route::get('/privacy', [PageController::class, 'privacy'])->name('privacy');
Route::get('/terms', [PageController::class, 'terms'])->name('terms');

Route::get('/return', [PageController::class, 'return'])->name('return');
Route::get('/refund', [PageController::class, 'refund'])->name('refund');

Route::get('/faq', [PageController::class, 'faq'])->name('faq');




Route::get('blog', [PageController::class, 'blog'])->name('blog_page');
Route::get('blogs/{slug}', [PageController::class, 'blogdetails'])->name('blog_page_details');
Route::get('contact-us', [PageController::class, 'contact'])->name('contact_page');
Route::post('submit-contact-form', [PageController::class, 'contactform'])->name('submit_contact_form');

Route::post('save-home-form', [PageController::class, 'savehomeform'])->name('save_home_form');

Route::get('/search/news', [PageController::class, 'searchNews'])->name('search.news');


//  Login and Register   //

Route::get('register', [UserLoginController::class, 'register_user'])->name('register_user');
Route::get('login-user', [UserLoginController::class, 'login_user'])->name('login_user');
Route::post('registration', [UserLoginController::class, 'registration'])->name('registration');
Route::post('user-login', [UserLoginController::class, 'user_login'])->name('user_login');

Route::get('products', [PageController::class, 'products'])->name('products');

Route::get('/products/{slug}', [PageController::class, 'showProducts'])->name('products.byCategory');


Route::get('/allproducts/{slug}', [PageController::class, 'showallProducts'])->name('products.bysubCategory');


Route::get('/products/allcategory/{slug}', [PageController::class, 'showallProductscategory'])->name('products.bymainCategory');



Route::get('product-details/{slug}', [PageController::class, 'product_details'])->name('product_details');

Route::get('cart', [PageController::class, 'cart'])->name('cart');




Route::get('/searchproduct', [PageController::class, 'prtdsearch'])->name('search_product');





Route::get('/payment', [PaymentController::class, 'showPaymentForm'])->name('payment.form');
Route::post('/payment/process', [PaymentController::class, 'processPayment'])->name('payment.process');
Route::post('/payment/success', [PaymentController::class, 'paymentSuccess'])->name('payment.success');
Route::post('/payment/failure', [PaymentController::class, 'paymentFailure'])->name('payment.failure');
Route::post('/payment/ipn/', [PaymentController::class, 'handleIPN'])->name('payment.ipn');

Route::get('/payment-redirect', [PaymentController::class, 'paymentRedirect'])->name('payment.redirect');




Route::middleware(['auth'])->group(function () {
    Route::patch('update-cart', [PageController::class, 'update'])->name('update.cart');
    Route::delete('remove-from-cart', [PageController::class, 'remove'])->name('remove.from.cart');
    Route::post('add-to-cart/{id}', [PageController::class, 'addToCart'])->name('add.to.cart');

    Route::get('checkout', [PageController::class, 'checkout'])->name('checkout');

    Route::post('order', [PageController::class, 'saveorder'])->name('save_order');

    Route::get('/show-order', [PageController::class, 'showorder'])->name('order_list');
    
    Route::get('/order-success/{order_id}', [PageController::class, 'orderSuccess'])->name('order.success');

    Route::get('/my-account', [PageController::class, 'myaccount'])->name('myaccount');

    Route::post('/save-account', [PageController::class, 'saveaccount'])->name('saveaccount');

    Route::get('/user/logout', [PageController::class, 'user_logout'])->name('user.logout');
    Route::get('wishlist', [PageController::class, 'wishlistIndex'])->name('wishlist_index');

    Route::post('/add-to-wishlist', [PageController::class, 'addToWishlist'])->name('add.to.wishlist');

    Route::post('/wishlist/remove', [PageController::class, 'removeFromWishlist'])->name('remove.from.wishlist');
    
    
    
    
    
    
    
    
//     Route::get('payment',[PaymentController::class,'index'])->name('payment_index');
// Route::post('/payment/initiate', [PaymentController::class, 'initiatePayment'])->name('payment.initiate');
// Route::post('/payment/callback', [PaymentController::class, 'paymentCallback'])->name('payment.callback');
// Route::get('/payment/success', [PaymentController::class, 'paymentSuccess'])->name('payment.success');
// Route::get('/payment/failure', [PaymentController::class, 'paymentFailure'])->name('payment.failure');



    
    
    
    
    
    
    
    
    
    
    
    
});
