<?php

use App\Http\Controllers\CommunityController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\DistrictController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\ManagerController;
use App\Http\Controllers\MemberController;
use App\Http\Controllers\MenuGrpController;
use App\Http\Controllers\UserController;
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('/', 'LoginController@index')->name('login');
Route::post('login-submit', [LoginController::class,'login'])->name('login.submit');


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

    Route::group(['prefix' => 'dashboard','middleware' => 'validate.user'],function() {
        Route::get('/', [DashboardController::class, 'index'])->name('dashboard.index');
    });

    Route::group(['prefix' => 'member','middleware' => 'validate.user'],function() {
        Route::get('/index', [MemberController::class, 'index'])->name('member.index');
        Route::post('/get-member-list', [MemberController::class, 'getUserList'])->name('get.member.list');       // List
        Route::get('/create', [MemberController::class, 'create'])->name('member.create'); // Add form
        Route::post('/store', [MemberController::class, 'store'])->name('member.store');   // Save
        Route::get('/edit/{id}', [MemberController::class, 'edit'])->name('member.edit');  // Edit form
        Route::post('/update/{id}', [MemberController::class, 'update'])->name('member.update'); // Update
        Route::get('/delete/{id}', [MemberController::class, 'delete'])->name('member.delete'); // Delete
        Route::get('/members/sample', [MemberController::class, 'downloadSample'])->name('members.downloadSample');
        Route::post('/members/import', [MemberController::class, 'import'])->name('member.import');
    });

    Route::group(['prefix' => 'cc','middleware' => 'validate.user'],function() {
        Route::get('/index', [CommunityController::class, 'index'])->name('cc.index');
        Route::post('/get-cc-list', [CommunityController::class, 'getUserList'])->name('get.cc.list');       // List
        Route::get('/create', [CommunityController::class, 'create'])->name('cc.create'); // Add form
        Route::post('/store', [CommunityController::class, 'store'])->name('cc.store');   // Save
        Route::get('/edit/{id}', [CommunityController::class, 'edit'])->name('cc.edit');  // Edit form
        Route::post('/update/{id}', [CommunityController::class, 'update'])->name('cc.update'); // Update
        Route::get('/delete/{id}', [CommunityController::class, 'delete'])->name('cc.delete'); // Delete
        Route::post('/cc/import', [CommunityController::class, 'import'])->name('cc.import');
        Route::get('/cc/sample', [CommunityController::class, 'downloadSample'])->name('cc.downloadSample');


    });

    Route::group(['prefix' => 'cm','middleware' => 'validate.user'],function() {
        Route::get('/index', [ManagerController::class, 'index'])->name('cm.index');       // List
        Route::post('/get-cm-list', [ManagerController::class, 'getUserList'])->name('get.cm.list');       // List
        Route::get('/create', [ManagerController::class, 'create'])->name('cm.create'); // Add form
        Route::post('/store', [ManagerController::class, 'store'])->name('cm.store');   // Save
        Route::get('/edit/{id}', [ManagerController::class, 'edit'])->name('cm.edit');  // Edit form
        Route::post('/update/{id}', [ManagerController::class, 'update'])->name('cm.update'); // Update
        Route::get('/delete/{id}', [ManagerController::class, 'delete'])->name('cm.delete'); // Delete
        Route::post('/cm/import', [ManagerController::class, 'import'])->name('cm.import');
        Route::get('/cm/sample', [ManagerController::class, 'downloadSample'])->name('cm.downloadSample');


    });

    Route::group(['prefix' => 'setting','middleware' => 'validate.user'],function() {
        Route::get('/get-blocks/{id}', [DistrictController::class, 'getBlockByDistrict'])->name('get.blocks.by.district');
    });

    Route::group(['prefix' => 'user','middleware' => 'validate.user'],function() {
        Route::get('/index', [UserController::class, 'index'])->name('user.index');
        Route::get('/create', [UserController::class, 'create'])->name('user.create');
        Route::post('/store', [UserController::class, 'store'])->name('user.store');
        Route::get('/edit/{id}', [UserController::class, 'edit'])->name('user.edit');
        Route::post('/update/{id}', [UserController::class, 'update'])->name('user.update');
//        Route::post('/get-menu-list', [UserController::class, 'getUserList'])->name('get.menu.list');
        Route::post('/user/toggle-status', [UserController::class, 'toggleStatus'])->name('user.toggleStatus');
    });

    Route::group(['prefix' => 'menugrp','middleware' => 'validate.user'],function() {
        Route::get('/', [MenuGrpController::class, 'index'])->name('menugrp.index');
        Route::get('/create', [MenuGrpController::class, 'create'])->name('menugrp.create');
        Route::post('/store', [MenuGrpController::class, 'store'])->name('menugrp.store');
        Route::get('/edit/{id}', [MenuGrpController::class, 'edit'])->name('menugrp.edit');
        Route::post('/update/{id}', [MenuGrpController::class, 'update'])->name('menugrp.update');
        Route::post('/get-menu-list', [MenuGrpController::class, 'getMenuList'])->name('get.menu.list');
    });

    Route::get('logout', [LoginController::class, 'logout'])->name('logout');

});

    // DASHBOARD
