<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SearchController;
use App\Http\Controllers\BroadcastController;

// Make welcome page the default first page
Route::get('/', [BroadcastController::class, 'welcome'])->name('home');
Route::get('/welcome', function () {
    return view('welcome');
});

Route::get('/search', [SearchController::class, 'index'])->name('search.index');

// Search by order number
Route::get('/order/{orderNo}', [SearchController::class, 'showOrder'])
    ->where('orderNo', '.*')
    ->name('order.show');

// Search by phone
Route::get('/phone', [SearchController::class, 'searchPhone'])->name('phone.search');

// API route
Route::get('/api/broadcasts/active', [BroadcastController::class, 'active'])->name('broadcasts.active');

// Messages index
Route::get('/messages', [BroadcastController::class, 'index'])->name('messages.index');

// Info main page
Route::get('/info', [BroadcastController::class, 'info'])->name('info');

// Individual section pages
Route::get('/info/locations', [BroadcastController::class, 'locations'])->name('info.locations');
Route::get('/info/services', [BroadcastController::class, 'services'])->name('info.services');
Route::get('/info/pricing', [BroadcastController::class, 'pricing'])->name('info.pricing');
Route::get('/info/timings', [BroadcastController::class, 'timings'])->name('info.timings');

// EasyPaisa payment page
Route::get('/easypaisa/{orderNo}', function ($orderNo) {
    // Get balance for this order
    $balanceService = app(\App\Services\OrderStatusService::class);
    $balance = $balanceService->getBalanceByOrder($orderNo);
    $name = $balanceService->getCustomerNameByOrder($orderNo);

    return view('easypaisa', compact('orderNo', 'balance', 'name'));
})->name('easypaisa.payment');
