<?php

use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Route;

Route::get('/clear', function () {
    \Illuminate\Support\Facades\Artisan::call('optimize:clear');
});

Route::get('/time', function () {
    $url = parse_url('?search=&date=12%2F04%2F2024');

    parse_str($url['query'], $query);
    $startDate = Carbon::parse(trim($query['date']), config('app.local_timezone'))
    // ->setTimezone(config('app.local_timezone'))
    ;
    dd($startDate->toDateTimeLocalString(), $startDate->toDateTimeString());
    $date = Carbon::now();
});

// User Support Ticket
Route::controller('TicketController')->prefix('ticket')->name('ticket.')->group(function () {
    Route::get('/', 'supportTicket')->name('index');
    Route::get('new', 'openSupportTicket')->name('open');
    Route::post('create', 'storeSupportTicket')->name('store');
    Route::get('view/{ticket}', 'viewTicket')->name('view');
    Route::post('reply/{ticket}', 'replyTicket')->name('reply');
    Route::post('close/{ticket}', 'closeTicket')->name('close');
    Route::get('download/{ticket}', 'ticketDownload')->name('download');
});


Route::get('/subscribe/plan', 'PlanController@plan')->name('plan');

Route::controller('SiteController')->group(function () {
    Route::get('/contact', 'contact')->name('contact');
    Route::post('/contact', 'contactSubmit');
    Route::get('/change/{lang?}', 'changeLanguage')->name('lang');

    Route::post('/file-upload', 'SiteController@fileUpload')->name('file.upload');
    Route::get('cookie-policy', 'cookiePolicy')->name('cookie.policy');

    Route::get('/cookie/accept', 'cookieAccept')->name('cookie.accept');

    Route::post('subscribe', 'subscribe')->name('subscribe');

    Route::get('blog', 'blog')->name('blog');
    Route::get('blog/{id}/{slug}', 'blogDetails')->name('blog.details');

    Route::get('policy/{slug}/{id}', 'policyPages')->name('policy.pages');

    Route::get('placeholder-image/{size}', 'placeholderImage')->name('placeholder.image');

    Route::get('/{slug}', 'pages')->name('pages');
    Route::get('/', 'index')->name('home');
});


Route::post('/webhook/razorpay', [PlanController::class, 'webhook']);