<?php

use App\Http\Controllers\Frontend\BookingController;
use App\Http\Controllers\Frontend\DashboardController;
use App\Http\Controllers\Frontend\GatewayController;
use App\Http\Controllers\Frontend\HomeController;
use App\Http\Controllers\Frontend\IpnController;
use App\Http\Controllers\Frontend\LocationController;
use App\Http\Controllers\Frontend\PageController;
use App\Http\Controllers\Frontend\SettingController;
use App\Http\Controllers\Frontend\SpaceController;
use App\Http\Controllers\Frontend\StatusController;
use App\Http\Controllers\Frontend\UserController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\CronJobController;

Route::get('/', [HomeController::class, 'home'])->name('home');
Route::post('subscriber', [HomeController::class, 'subscribeNow'])->name('subscriber');

// Dynamic Page
Route::get('page/{section}', [PageController::class, 'getPage'])->name('dynamic.page');
Route::get('blog/{id}', [PageController::class, 'blogDetails'])->name('blog-details');
Route::post('mail-send', [PageController::class, 'mailSend'])->name('mail-send');

// Spaces and Locations
Route::get('spaces', [SpaceController::class, 'index'])->name('spaces');
Route::get('space-details/{id}', [SpaceController::class, 'serviceDetails'])->name('service.details');
Route::get('location-details/{id}', [LocationController::class, 'locationDetails'])->name('location.details');

// Site others
Route::get('theme-mode', [HomeController::class, 'themeMode'])->name('mode-theme');

// User Dashboard
Route::group(['middleware' => ['auth', setting('email_verification', 'permission') ? 'verified' : 'web'], 'prefix' => 'user', 'as' => 'user.'], function () {

    // Dashboard
    Route::get('dashboard', [DashboardController::class, 'dashboard'])->name('dashboard');

    // Change Password
    Route::get('/change-password', [UserController::class, 'changePassword'])->name('change.password');
    Route::post('/password-store', [UserController::class, 'newPassword'])->name('new.password');

    // Settings
    Route::group(['prefix' => 'settings', 'as' => 'setting.', 'controller' => SettingController::class], function () {
        Route::get('/', 'settings')->name('show');
        Route::post('profile-update', 'profileUpdate')->name('profile-update');
    });

    // Booking
    Route::group(['prefix' => 'booking', 'as' => 'booking.', 'controller' => BookingController::class], function () {
        Route::get('/', 'bookings')->name('index');
        Route::get('checkout/{id?}', 'checkout')->name('checkout');
        Route::post('place/{id?}', 'place')->name('place');
        Route::get('/booked/{id}', 'booked')->name('booked');
        Route::post('payment/{id}', 'paymentNow')->name('payment');
        Route::get('gateway-details/{id}', 'gatewayDetails')->name('gateway.details');
        Route::get('invoice/{id}', 'invoice')->name('invoice');
    });
});

// Translate
Route::get('language-update', [HomeController::class, 'languageUpdate'])->name('language-update');

// Gateway Manage
Route::get('gateway-list', [GatewayController::class, 'gatewayList'])->name('gateway.list')->middleware('XSS', 'translate', 'auth');

// Gateway status
Route::group(['controller' => StatusController::class, 'prefix' => 'status', 'as' => 'status.'], function () {
    Route::match(['get', 'post'], '/success', 'success')->name('success');
    Route::match(['get', 'post'], '/cancel', 'cancel')->name('cancel');
    Route::match(['get', 'post'], '/pending', 'pending')->name('pending');
});

// Instant payment notification
Route::group(['prefix' => 'ipn', 'as' => 'ipn.', 'controller' => IpnController::class], function () {
    Route::post('coinpayments', 'coinpaymentsIpn')->name('coinpayments');
    Route::post('nowpayments', 'nowpaymentsIpn')->name('nowpayments');
    Route::post('cryptomus', 'cryptomusIpn')->name('cryptomus');
    Route::get('paypal', 'paypalIpn')->name('paypal');
    Route::post('mollie', 'mollieIpn')->name('mollie');
    Route::any('perfectmoney', 'perfectMoneyIpn')->name('perfectMoney');
    Route::get('paystack', 'paystackIpn')->name('paystack');
    Route::get('flutterwave', 'flutterwaveIpn')->name('flutterwave');
    Route::post('coingate', 'coingateIpn')->name('coingate');
    Route::get('monnify', 'monnifyIpn')->name('monnify');
    Route::get('non-hosted-securionpay', 'nonHostedSecurionpayIpn')->name('non-hosted.securionpay')->middleware(['auth', 'XSS']);
    Route::post('coinremitter', 'coinremitterIpn')->name('coinremitter');
    Route::post('btcpay', 'btcpayIpn')->name('btcpay');
    Route::post('binance', 'binanceIpn')->name('binance');
    Route::get('blockchain', 'blockchainIpn')->name('blockchain');
    Route::get('instamojo', 'instamojoIpn')->name('instamojo');
    Route::post('paytm', 'paytmIpn')->name('paytm');
    Route::post('razorpay', 'razorpayIpn')->name('razorpay');
    Route::post('twocheckout', 'twocheckoutIpn')->name('twocheckout');
});

// Cron Job
Route::get('cron-job/booking-cron',[CronJobController::class,'bookingExpire'])->name('booking-cron');