<?php

use App\Http\Controllers\DataSettingController;
use App\Http\Controllers\Dashboards\BigDataController;
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 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');
    });
    
    // 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');
    });
});