<?php

use App\Http\Controllers\BusinessOrIndustriesController;
use App\Http\Controllers\CustomersController;
use App\Http\Controllers\Dashboards\LackOfPotentialController;
use App\Http\Controllers\DataSettingController;
use App\Http\Controllers\Dashboards\BigDataController;
use App\Http\Controllers\GoogleApisController;
use App\Http\Controllers\Home\HomeController;
use App\Http\Controllers\Master\UsersController;
use App\Http\Controllers\MenusController;
use App\Http\Controllers\RequestAssignment\PbgTaskController;
use App\Http\Controllers\RolesController;
use App\Http\Controllers\Settings\SettingsController;
use App\Http\Controllers\Settings\SyncronizeController;
use App\Http\Controllers\Data\AdvertisementController;
use App\Http\Controllers\Data\UmkmController;
use App\Http\Controllers\Data\TourismController;
use App\Http\Controllers\Data\SpatialPlanningController;
use App\Http\Controllers\Report\ReportTourismController;
use App\Http\Controllers\SpatialPlanningsController;
use Illuminate\Support\Facades\Route;

require __DIR__ . '/auth.php';

// auth 
Route::group(['middleware' => 'auth'], function(){

    Route::get('', [BigDataController::class, 'index'])->name('any');

    //dashboards
    Route::group(['prefix' => '/dashboards'], function(){
        Route::get('/bigdata', [BigDataController::class, 'index'])->name('dashboard.home');
        Route::get('/dashboard-pbg', [BigDataController::class, 'pbg'])->name('dashboard.pbg');
        Route::get('/lack-of-potential', [LackOfPotentialController::class, 'lack_of_potential'])->name('dashboard.lack_of_potential');
        Route::get('/maps', [GoogleApisController::class, 'index'])->name('dashboard.maps');
    });
    
    // settings
    Route::group(['prefix' => '/settings'], function(){
        Route::resource('/general', SettingsController::class);
        Route::get('/syncronize', [SyncronizeController::class, 'index'])->name('settings.syncronize');
        Route::post('/syncronize', [SyncronizeController::class, 'syncronizeTask'])->name('settings.sync');
    });

    // masters
    Route::group(['prefix' => '/master'], function (){
        Route::resource('/users', UsersController::class);
        Route::get('/all-users', [UsersController::class, 'allUsers'])->name('users.all');
    });

    // data - PBG
    Route::resource('/pbg-task', PbgTaskController::class);

    // data settings
    Route::resource('/data-settings', DataSettingController::class);

    // menus
    Route::resource('/menus', MenusController::class);

    // roles
    Route::resource('/roles', RolesController::class);
    Route::group(['prefix' => '/roles'], function (){
        Route::get('/role-menu/{role_id}', [RolesController::class, 'menu_permission'])->name('role-menu.permission');
        Route::put('/role-menu/{role_id}', [RolesController::class, 'update_menu_permission'])->name('role-menu.permission.update');
    });

    // data
    Route::group(['prefix' => '/data'], function(){
        // Resource route, kecuali create karena dibuat terpisah
        Route::resource('/advertisements', AdvertisementController::class)->except(['create', 'show']);

        // Rute khusus untuk create dan bulk-create
        Route::get('/advertisements/create', [AdvertisementController::class, 'create'])->name('advertisements.create');
        Route::get('/advertisements/bulk-create', [AdvertisementController::class, 'bulkCreate'])->name('advertisements.bulk-create');

        // Resource route, kecuali create karena dibuat terpisah
        Route::resource('/umkm', UmkmController::class)->except(['create', 'show']);

        // Rute khusus untuk create dan bulk-create
        Route::get('/umkm/create', [UmkmController::class, 'create'])->name('umkm.create');
        Route::get('/umkm/bulk-create', [UmkmController::class, 'bulkCreate'])->name('umkm.bulk-create');

        // Resource route, kecuali create karena dibuat terpisah
        Route::resource('/tourisms', TourismController::class)->except(['create', 'show']);
        // Rute khusus untuk create dan bulk-create
        Route::get('/tourisms/create', [TourismController::class, 'create'])->name('tourisms.create');
        Route::get('/tourisms/bulk-create', [TourismController::class, 'bulkCreate'])->name('tourisms.bulk-create');

        // Resource route, kecuali create karena dibuat terpisah
        Route::resource('/spatial-plannings', SpatialPlanningController::class)->except(['create', 'show']);
        // Rute khusus untuk create dan bulk-create
        Route::get('/spatial-plannings/create', [SpatialPlanningController::class, 'create'])->name('tourisms.create');
        Route::get('/spatial-plannings/bulk-create', [SpatialPlanningController::class, 'bulkCreate'])->name('tourisms.bulk-create');
        

        Route::resource('/business-industries',BusinessOrIndustriesController::class);

        Route::controller(CustomersController::class)->group( function (){
            Route::get('/customers', 'index')->name('customers');
            Route::get('/customers/create', 'create')->name('customers.create');
            Route::get('/customers/{customer_id}/edit', 'edit')->name('customers.edit');
            Route::get('/customers/upload', 'upload')->name('customers.upload');
        });
    });

    // Report
    Route::group(['prefix' => '/report'], function(){
        // Resource route, kecuali create karena dibuat terpisah
        Route::resource('/tourisms-report', ReportTourismController::class);
    });
});