<?php

use App\Http\Controllers\PercobaanController;
use App\Http\Controllers\Website\AlternatifReferensiController;
use App\Http\Controllers\Website\ListDataKriteriaController;
use App\Http\Controllers\Website\ListSubDistrictController;
use App\Http\Controllers\Website\ParameterHeightSubDistrictController;
use App\Http\Controllers\Website\ParameterHeightVillageController;
use App\Http\Controllers\Website\ParameterListHeightSubDistrictController;
use App\Http\Controllers\Website\ParameterListPhSubDistrictController;
use App\Http\Controllers\Website\ParameterListWeatherSubDistrictController;
use App\Http\Controllers\Website\ParameterPhSubDistrictController;
use App\Http\Controllers\Website\ParameterPhVillageController;
use App\Http\Controllers\Website\ParameterSubDistrictController;
use App\Http\Controllers\Website\ParameterVillageController;
use App\Http\Controllers\Website\PlantController;
use App\Http\Controllers\Website\SubDistrictAlternatifController;
use App\Http\Controllers\Website\SubDistrictResultPreferenceController;
use App\Http\Controllers\Website\ProfileController;
use App\Http\Controllers\LandingPage\HomeController;
use App\Http\Controllers\Website\ProfileUpdateController;
use App\Http\Controllers\Website\DashboardController;
use App\Http\Controllers\Auth\RegistrasiController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\LandingPage\ResultPreferensiSubDistrictController;
use App\Http\Controllers\Website\ListUserController;
use App\Http\Controllers\Website\ListVillageController;
use App\Http\Controllers\Website\ParameterListHeightVillageController;
use App\Http\Controllers\Website\ParameterListPhVillageController;
use App\Http\Controllers\Website\ParameterListWeatherVillageController;
use App\Http\Controllers\Website\VillageAlternatifController;
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 and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

// Route::get('/', function () {
//     return view('welcome');
// });
// Route::get('/percobaan', [PercobaanController::class, 'index'])->name('website.percobaan');

// LOGIN
Route::prefix('login')->middleware('guest')->controller(LoginController::class)->name('login.')->group(function () {
    Route::get('/', 'index')->name('index');
    Route::post('/login', 'login')->name('login');
});

// REGISTRASI
Route::prefix('registrasi')->middleware('guest')->controller(RegistrasiController::class)->name('registrasi.')->group(function () {
    Route::get('/', 'index')->name('index');
    Route::post('/registrasi', 'registrasi')->name('registrasi');
});

// LOGOUT
Route::post('/logout', [LoginController::class, 'logout'])->middleware('auth')->name('logout');

// Halaman Landing Page
Route::prefix('home')->controller(HomeController::class)->name('home.')->group(function () {
    Route::get('/', 'index')->name('index');
});

Route::prefix('hasil-preferensi')->controller(ResultPreferensiSubDistrictController::class)->name('user-result-preferensi.')->group(function () {
    Route::get('/', 'index')->name('index');
    Route::get('/getResultSubDistrictByYear/{year}', 'getResultSubDistrictByYear')->name('getResultSubDistrictByYear');
});

Route::middleware(['auth'])->group(function () {
    // USER
    Route::middleware(['auth', 'user'])->group(function () {
        Route::get('/percobaan', [PercobaanController::class, 'index'])->name('website.percobaan');
    });

    // ADMIN
    Route::middleware(['auth', 'admin'])->group(function () {
        // Halaman Profile
        Route::prefix('profile')->controller(ProfileController::class)->name('profile.')->group(function () {
            Route::get('/', 'index')->name('index');
        });
        Route::prefix('profile-ubah')->controller(ProfileUpdateController::class)->name('profile-update.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::post('/update', 'update')->name('update');
            Route::post('/updatePassword', 'updatePassword')->name('updatePassword');
        });

        // Dashboard
        Route::prefix('dashboard')->controller(DashboardController::class)->name('dashboard.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getResultSubDistrictByYear/{year}', 'getResultSubDistrictByYear')->name('getResultSubDistrictByYear');
        });

        // List user
        Route::prefix('list-user')->controller(ListUserController::class)->name('list-user.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getListUserData', 'getListUserData')->name('getListUserData');
            Route::post('/updateListUser', 'updateListUser')->name('updateListUser');
            Route::get('/deleteUser/{id}', 'deleteUser')->name('deleteUser');
        });

        // parameter sub_district
        Route::prefix('parameter-kecamatan')->controller(ParameterSubDistrictController::class)->name('parameter-sub-district.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataSubDistrict', 'getDataSubDistrict')->name('getDataSubDistrict');
            Route::get('{latitude}/{longitude}/{year}', 'excelParameterSubDistrict')->name('excelParameterSubDistrict');
        });

        // list parameter weather sub_district
        Route::prefix('list-parameter-cuaca-kecamatan')->controller(ParameterListWeatherSubDistrictController::class)->name('parameter-list-weather-sub-district.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataParameterListWeatherSubDistrict/{year}', 'getDataParameterListWeatherSubDistrict')->name('getDataParameterListWeatherSubDistrict');
            Route::get('/{years}', 'updateListParameterWeatherSubDistrict')->name('updateListParameterWeatherSubDistrict');
        });

        // list parameter ph sub_district
        Route::prefix('list-parameter-ph-kecamatan')->controller(ParameterListPhSubDistrictController::class)->name('parameter-list-ph-sub-district.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataParameterListPhSubDistrict', 'getDataParameterListPhSubDistrict')->name('getDataParameterListPhSubDistrict');
            Route::get('/updateListParameterPhSubDistrict', 'updateListParameterPhSubDistrict')->name('updateListParameterPhSubDistrict');
        });

        // list parameter height sub_district
        Route::prefix('list-parameter-ketinggian-kecamatan')->controller(ParameterListHeightSubDistrictController::class)->name('parameter-list-height-sub-district.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/{years}', 'getDataParameterListHeightSubDistrict')->name('getDataParameterListHeightSubDistrict');
            Route::post('/addListHeightSubDistrict', 'addListHeightSubDistrict')->name('addListHeightSubDistrict');
            Route::post('/updateListHeightSubDistrict', 'updateListHeightSubDistrict')->name('updateListHeightSubDistrict');
            Route::get('/deleteListHeightSubDistrict/{id}', 'deleteListHeightSubDistrict')->name('deleteListHeightSubDistrict');
        });

        // parameter phH2O sub_district
        Route::prefix('parameter-ph-kecamatan')->controller(ParameterPhSubDistrictController::class)->name('parameter-ph-sub-district.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataPhSubDistrict', 'getDataPhSubDistrict')->name('getDataPhSubDistrict');
            Route::get('{latitude}/{longitude}', 'excelParameterPhSubDistrict')->name('excelParameterPhSubDistrict');
        });

        // parameter height sub_district
        Route::prefix('parameter-ketinggian-kecamatan')->controller(ParameterHeightSubDistrictController::class)->name('parameter-height-sub-district.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataHeightSubDistrict', 'getDataHeightSubDistrict')->name('getDataHeightSubDistrict');
            Route::get('/{year}', 'excelParameterHeightSubDistrict')->name('excelParameterHeightSubDistrict');
        });

        // parameter village
        Route::prefix('parameter-desa')->controller(ParameterVillageController::class)->name('parameter-village.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataVillage', 'getDataVillage')->name('getDataVillage');
            Route::get('{latitude}/{longitude}/{year}', 'excelParameterVillage')->name('excelParameterVillage');
        });

        // parameter phH2O village
        Route::prefix('parameter-ph-desa')->controller(ParameterPhVillageController::class)->name('parameter-ph-village.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataPhVillage', 'getDataPhVillage')->name('getDataPhVillage');
            Route::get('{latitude}/{longitude}', 'excelParameterPhVillage')->name('excelParameterPhVillage');
        });

        // parameter height village
        Route::prefix('parameter-ketinggian-desa')->controller(ParameterHeightVillageController::class)->name('parameter-height-village.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataHeightVillage', 'getDataHeightVillage')->name('getDataHeightVillage');
            Route::get('/{year}', 'excelParameterHeightVillage')->name('excelParameterHeightVillage');
        });

        // list parameter weather village
        Route::prefix('list-parameter-cuaca-desa')->controller(ParameterListWeatherVillageController::class)->name('parameter-list-weather-village.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataParameterListWeatherVillage/{years}/{subDistrictId}', 'getDataParameterListWeatherVillage')->name('getDataParameterListWeatherVillage');
            Route::get('/{years}/{subDistrictId}', 'updateListParameterWeatherVillage')->name('updateListParameterWeatherVillage');
        });

        // list parameter ph sub_district
        Route::prefix('list-parameter-ph-desa')->controller(ParameterListPhVillageController::class)->name('parameter-list-ph-village.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataParameterListPhVillage/{subDistrictId}', 'getDataParameterListPhVillage')->name('getDataParameterListPhVillage');
            Route::get('/updateListParameterPhVillage/{subDistrictId}', 'updateListParameterPhVillage')->name('updateListParameterPhVillage');
        });

        // list parameter height village
        Route::prefix('list-parameter-ketinggian-desa')->controller(ParameterListHeightVillageController::class)->name('parameter-list-height-village.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getDataParameterListHeightVillage/{year}/{subDistrictId}', 'getDataParameterListHeightVillage')->name('getDataParameterListHeightVillage');
            Route::get('/getVillage/{id}', 'getVillage')->name('getVillage');
            Route::post('/addListHeightVillage', 'addListHeightVillage')->name('addListHeightVillage');
            Route::post('/updateListHeightVillage', 'updateListHeightVillage')->name('updateListHeightVillage');
            Route::get('/deleteListHeightVillage/{id}', 'deleteListHeightVillage')->name('deleteListHeightVillage');
        });

        // perhitungan | list data kriteria
        Route::prefix('list-data-kriteria')->controller(ListDataKriteriaController::class)->name('list-data-kriteria.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getListCriteriaData', 'getListCriteriaData')->name('getListCriteriaData');
            Route::post('/addCriteria', 'addCriteria')->name('addCriteria');
            Route::post('/updateCriteria', 'updateCriteria')->name('updateCriteria');
            Route::get('/deleteCriteria/{id}', 'deleteCriteria')->name('deleteCriteria');
        });

        // perhitungan | list data tanaman
        Route::prefix('list-data-tanaman')->controller(PlantController::class)->name('list-plant.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getListPlantData', 'getListPlantData')->name('getListPlantData');
            Route::post('/addPlant', 'addPlant')->name('addPlant');
            // Route::post('/updatePlant', 'updatePlant')->name('updatePlant');
            Route::get('/deletePlant/{id}', 'deletePlant')->name('deletePlant');
        });

        // perhitungan | list data sub district
        Route::prefix('list-data-kecamatan')->controller(ListSubDistrictController::class)->name('list-sub-district.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getListSubDistrict', 'getListSubDistrict')->name('getListSubDistrict');
            Route::post('/addSubDistrict', 'addSubDistrict')->name('addSubDistrict');
            Route::post('/updateSubDistrict', 'updateSubDistrict')->name('updateSubDistrict');
            Route::get('/deleteSubDistrict/{id}', 'deleteSubDistrict')->name('deleteSubDistrict');
        });

        // perhitungan | list data village
        Route::prefix('list-data-desa')->controller(ListVillageController::class)->name('list-village.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getListVillage/{subDistrictId}', 'getListVillage')->name('getListVillage');
            Route::post('/addVillage', 'addVillage')->name('addVillage');
            Route::post('/updateVillage', 'updateVillage')->name('updateVillage');
            Route::get('/deleteVillage/{id}', 'deleteVillage')->name('deleteVillage');
        });

        // perhitungan | kalkulasi referensi | alternatif
        Route::prefix('alternatif-referensi')->controller(AlternatifReferensiController::class)->name('alternatif-referensi.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::post('/addAlternatifReferensi', 'addAlternatifReferensi')->name('addAlternatifReferensi');
            Route::post('/updateAlternatifReferensi', 'updateAlternatifReferensi')->name('updateAlternatifReferensi');
            Route::get('/deleteAlternatifReferensi/{id}', 'deleteAlternatifReferensi')->name('deleteAlternatifReferensi');
            Route::get('/getListAlternatifReferensi', 'getListAlternatifReferensi')->name('getListAlternatifReferensi');
            Route::get('/addPreferensiResultReferensi', 'addPreferensiResultReferensi')->name('addPreferensiResultReferensi');
        });

        // perhitungan | sub district alternatif
        Route::prefix('alternatif-kecamatan')->controller(SubDistrictAlternatifController::class)->name('sub-district-alternatif.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getAlternatifSubDistrict/{month}/{year}', 'getAlternatifSubDistrict')->name('getAlternatifSubDistrict');
            Route::post('/addAlternatifSubDistrict', 'addAlternatifSubDistrict')->name('addAlternatifSubDistrict');
            Route::post('/updateAlternatifBySubDistrict', 'updateAlternatifBySubDistrict')->name('updateAlternatifBySubDistrict');
            Route::get('/deleteAlternatifSubDistrict/{id}/{month}/{year}', 'deleteAlternatifSubDistrict')->name('deleteAlternatifSubDistrict');
            Route::get('/{month}/{year}', 'updateAlternatifSubDistrict')->name('updateAlternatifSubDistrict');
        });

        // perhitungan | sub district result preference
        Route::prefix('hasil-preferensi-kecamatan')->controller(SubDistrictResultPreferenceController::class)->name('sub-district-result-preference.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getSubDistrictResultPreference/{month}/{year}', 'getSubDistrictResultPreference')->name('getSubDistrictResultPreference');
        });

        // perhitungan | village alternatif
        Route::prefix('alternatif-desa')->controller(VillageAlternatifController::class)->name('village-alternatif.')->group(function () {
            Route::get('/', 'index')->name('index');
            Route::get('/getAlternatifVillage/{month}/{years}/{subDistrictId}', 'getAlternatifVillage')->name('getAlternatifVillage');
            Route::get('/getVillage/{id}', 'getVillage')->name('getVillage');
            Route::post('/addAlternatifVillage', 'addAlternatifVillage')->name('addAlternatifVillage');
            Route::post('/updateAlternatifByVillage', 'updateAlternatifByVillage')->name('updateAlternatifByVillage');
            Route::get('/deleteAlternatifVillage/{id}/{month}/{year}', 'deleteAlternatifVillage')->name('deleteAlternatifVillage');
            Route::get('/{month}/{years}/{subDistrictId}', 'updateAlternatifVillage')->name('updateAlternatifVillage');
        });
    });
});
