<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Artisan;
use App\Http\Controllers\Admin\AdminController;


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


Route::get('cron', 'CronController@cron')->name('cron');

Route::get('/clear-all-cache', function () {
    // Clear application cache
    Artisan::call('cache:clear');

    // Clear route cache
    Artisan::call('route:clear');

    // Clear config cache
    Artisan::call('config:clear');

    // Clear view cache
    Artisan::call('view:clear');

    // Clear compiled services
    Artisan::call('clear-compiled');

    return 'All caches cleared!';
});

Route::get('admin/claims/{id}', function ($id) {
    // Retrieve the claim by its ID from the database
    $claim = DB::table('claims')->where('id', $id)->first();

    // Return the view with the claim data
    $pageTitle = 'Refund Claim Details';
    return view('admin.support.claim_details', compact('claim', 'pageTitle'));
    })->name('claims.show');


Route::controller('SiteController')->group(function () {
    Route::get('contact', 'contact')->name('contact');
    Route::post('contact', 'contactSubmit');
    Route::get('change/{lang?}', 'changeLanguage')->name('lang');
    Route::get('cookie-policy', 'cookiePolicy')->name('cookie.policy');
    Route::get('cookie/accept', 'cookieAccept')->name('cookie.accept');
    Route::get('policy/{slug}', 'policyPages')->name('policy.pages');
    Route::get('placeholder-image/{size}', 'placeholderImage')->withoutMiddleware('maintenance')->name('placeholder.image');
    Route::get('maintenance-mode', 'maintenance')->withoutMiddleware('maintenance')->name('maintenance');
    Route::get('session-status', 'sessionStatus')->name('session.status');
    Route::post('subscribe', 'addSubscriber')->name('subscribe');
    Route::get('branches', 'branches')->name('branches');
    Route::view('/international_shipping', 'services.international_shipping')->name('international_shipping');
Route::view('/domestic_shipping', 'services.domestic_shipping')->name('domestic_shipping');
Route::view('/cargo_freight', 'services.cargo_freight')->name('cargo_freight');
Route::view('/pet_delivery', 'services.pet_delivery')->name('pet_delivery');
Route::view('/e_commerce', 'services.e_commerce')->name('e_commerce');
Route::view('/customs', 'services.customs')->name('customs');
Route::view('/warehouse', 'services.warehouse')->name('warehouse');
Route::view('/special_cargo', 'services.special_cargo')->name('special_cargo');
Route::view('/supply_chain', 'services.supply_chain')->name('supply_chain');
Route::get('/company', function () {
    return view('about.company');
})->name('company');

Route::get('/network', function () {
    return view('about.network');
})->name('network');

Route::get('/fleet', function () {
    return view('about.fleet');
})->name('fleet');

Route::get('/compliance', function () {
    return view('about.compliance');
})->name('compliance');
Route::view('/shipping_policy', 'policies.shipping_policy');
Route::view('/returns_policy', 'policies.returns_policy');
Route::view('/cargo_safety', 'policies.cargo_safety');
Route::view('/customs_policy', 'policies.customs_policy');
Route::view('/insurance_policy', 'policies.insurance_policy');
Route::view('/payment_policy', 'policies.payment_policy');
Route::view('/privacy_policy', 'policies.privacy_policy');
Route::view('/terms', 'policies.terms');
Route::view('/reviews', 'info.reviews')->name('reviews');
Route::view('/faqs', 'info.faqs')->name('faqs');
Route::view('/partnerships', 'info.partnerships')->name('partnerships');
Route::view('/careers', 'info.careers')->name('careers');
Route::view('/tracking', 'tracking')->name('tracking');
Route::view('/contact_us', 'contact_us')->name('contact_us');
    Route::post('shipment', 'shipment')->name('shipment');

});


// Home Page
Route::get('/', function () {
    return view('home');
})->name('home');

Route::view('/international_shipping', 'services.international_shipping')->name('international_shipping');
Route::view('/domestic_shipping', 'services.domestic_shipping')->name('domestic_shipping');
Route::view('/cargo_freight', 'services.cargo_freight')->name('cargo_freight');
Route::view('/pet_delivery', 'services.pet_delivery')->name('pet_delivery');
Route::view('/e_commerce', 'services.e_commerce')->name('e_commerce');
Route::view('/customs', 'services.customs')->name('customs');
Route::view('/warehouse', 'services.warehouse')->name('warehouse');
Route::view('/special_cargo', 'services.special_cargo')->name('special_cargo');
Route::view('/supply_chain', 'services.supply_chain')->name('supply_chain');

// Document download routes
Route::get('/shipments/{tracking_number}/download/{document}', [AdminController::class, 'downloadDocument'])->name('shipments.download-document');
Route::get('/shipments/{tracking_number}/download-all', [AdminController::class, 'downloadAllDocuments'])->name('shipments.download-all');


Route::get('/shipments/{tracking_number}/preview/{document}', [AdminController::class, 'previewDocument'])->name('shipments.preview-document');