<?php

use App\Http\Controllers\AuthController;
use App\Http\Controllers\DataController;
use App\Http\Controllers\EmployeeController;
use App\Http\Controllers\ImportController;
use App\Http\Controllers\PrizeController;
use App\Http\Controllers\RaffleDrawController;
use App\Http\Controllers\SettingsController;
use App\Http\Controllers\WebsiteController;
use App\Http\Controllers\WinnerController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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('/', function () {
    return view('index');
})->name("home");

Route::post('/check-location', [WebsiteController::class, 'checkLocation'])->name('check_location');


Route::post('submit-form', [WebsiteController::class, 'store'])->name('form.submit'); 

//------------------Admin------------------------
Route::get('login', [AuthController::class, 'index'])->name('login');
Route::post('post-login', [AuthController::class, 'postLogin'])->name('login.post'); 
Route::get('registration', [AuthController::class, 'registration'])->name('register');
Route::post('post-registration', [AuthController::class, 'postRegistration'])->name('register.post'); 

Route::prefix('admin')->middleware('auth')->group(function () {

    Route::get('/', [AuthController::class, 'dashboard']);
    Route::get('dashboard', [AuthController::class, 'dashboard'])->name('dashboard'); 
    Route::post('change-password', [AuthController::class, 'changePassword'])->name('change_password');
    Route::get('logout', [AuthController::class, 'logout'])->name('logout');



    // Formdata starts
    Route::get('formdata', [DataController::class, 'index'])->name('formdata');
    Route::post('formdata-post', [DataController::class, 'formdata'])->name('formdata.post');
    Route::post('formdata-search', [DataController::class, 'searchFormdata'])->name('formdata.search');

    Route::get('formdata-export',  [DataController::class, 'export'])->name('formdata.export');
    // Formdata ends


    // Importdata starts
    Route::get('importdata', [ImportController::class, 'index'])->name('importdata');
    Route::post('importdata-post', [ImportController::class, 'importdata'])->name('importdata.post');
    Route::post('importdata-search', [ImportController::class, 'searchImportdata'])->name('importdata.search');
    
    Route::post('data-import', [ImportController::class, 'import'])->name('importdata.import');
    Route::get('importdata-export',  [ImportController::class, 'export'])->name('importdata.export');
    Route::get('send-sms',  [ImportController::class, 'sendSMS'])->name('send.sms');
    // Importdata ends

    // Employeedata starts
    Route::get('employee_data', [EmployeeController::class, 'index'])->name('employee_data');
    Route::post('employee_data-post', [EmployeeController::class, 'importdata'])->name('employee_data.post');
    // Route::post('employee_data-search', [EmployeeController::class, 'searchImportdata'])->name('employee_data.search');
    
    Route::post('data-employee-import', [EmployeeController::class, 'import'])->name('employee_data.import');
    // Route::get('employee_data-export',  [EmployeeController::class, 'export'])->name('employee_data.export');
    // Employeedata ends
    

    // Prize settings starts
    Route::get('prize-settings', [PrizeController::class, 'index'])->name('prize_settings');
    Route::post('prize-store', [PrizeController::class, 'store'])->name('prize.store');
    Route::post('prize-show', [PrizeController::class, 'show'])->name('prize.show');
    Route::post('prize-update', [PrizeController::class, 'update'])->name('prize.update');
    Route::post('prize-delete', [PrizeController::class, 'delete'])->name('prize.delete');

    Route::post('prize-category-store', [PrizeController::class, 'storeCategory'])->name('prize-category.store');
    Route::post('prize-category-show', [PrizeController::class, 'showCategory'])->name('prize-category.show');
    Route::post('prize-category-update', [PrizeController::class, 'updateCategory'])->name('prize-category.update');
    Route::post('prize-category-delete', [PrizeController::class, 'deleteCategory'])->name('prize-category.delete');

    Route::post('prize-week-store', [PrizeController::class, 'storeWeek'])->name('prize-week.store');
    Route::post('prize-week-show', [PrizeController::class, 'showWeek'])->name('prize-week.show');
    Route::post('prize-week-update', [PrizeController::class, 'updateWeek'])->name('prize-week.update');
    Route::post('prize-week-delete', [PrizeController::class, 'deleteWeek'])->name('prize-week.delete');

    // Prize settings ends


    // Raffle Draw starts
    Route::get('raffle-draw-menu', [SettingsController::class, 'index'])->name('raffle_draw.menu');
    Route::post('settings-show', [SettingsController::class, 'show'])->name('settings.show');
    Route::post('settings-update', [SettingsController::class, 'update'])->name('settings.update');

    Route::get('reset-raffle-draw', [WinnerController::class, 'resetData'])->name('reset.raffledraw');
    
    // Raffle Draw ends

    // Winners starts
    Route::get('winners', [WinnerController::class, 'index'])->name('winners');
    Route::post('winners', [WinnerController::class, 'index'])->name('winners.search');
    Route::get('winners-export',  [WinnerController::class, 'export'])->name('winners.export');

    // Winners ends

});

Route::middleware('auth')->group(function () {

    // Raffle Draw starts
    Route::get('raffle-draw/{url_slug}', [RaffleDrawController::class, 'raffleDraw'])->name('raffle_draw');
    Route::post('raffle-draw-post', [RaffleDrawController::class, 'raffleDrawPost'])->name('raffle_draw.post');
    Route::post('winner', [RaffleDrawController::class, 'showWinner'])->name('winner.show');
    // Raffle Draw ends

});