<?php

use App\Http\Controllers\AdminController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;

/*
|--------------------------------------------------------------------------
| 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!
|
*/


// Giao diện Admin

Route::get('dangnhap', [AdminController::class, 'index'])->name('login');
Route::post('dangnhap', [AdminController::class, 'post_login']);
Route::get('signout', [AdminController::class, 'signOut'])->name('signout');
Route::get('quen-mat-khau', [AdminController::class, 'get_quenmatkhau'])->name('quenmatkhau');
Route::post('quen-mat-khau', [AdminController::class, 'post_quenmatkhau']);
Route::get('lay-lai-mat-khau/{token}', [AdminController::class, 'get_laylaimatkhau'])->name('get_laylaimatkhau');
Route::post('lay-lai-mat-khau', [AdminController::class, 'post_laylaimatkhau'])->name('post_laylaimatkhau');

Route::prefix('admin')->middleware('authAdmin')->group(function(){
    Route::get('/', [AdminController::class, 'get_main'])->name('admin');

    Route::prefix('quanlythongtin')->group(function(){
        Route::get('/', [AdminController::class, 'get_quanlythongtin'])->name('quanlythongtin');

        Route::get('/nhapdulieutrungtuyen', [AdminController::class, 'get_nhapdulieutrungtuyen'])->name('nhapdulieutrungtuyen');
        Route::post('/nhapdulieutrungtuyen', [AdminController::class, 'post_nhapdulieutrungtuyen'])->name('post_nhapdulieutrungtuyen');
        Route::get('/search_trungtuyen', [AdminController::class, 'search_trungtuyen'])->middleware('verifyPermission:0')->name('search_trungtuyen');
        Route::post('/update_nhapdulieutrungtuyen', [AdminController::class, 'update_nhapdulieutrungtuyen'])->name('update_nhapdulieutrungtuyen');
        Route::get('/del_nhapdulieutrungtuyen/{stt}', [AdminController::class, 'del_nhapdulieutrungtuyen'])->name('del_nhapdulieutrungtuyen');

        Route::get('/suabangdulieutrungtuyen', [AdminController::class, 'get_suabangdulieutrungtuyen'])->name('suabangdulieutrungtuyen');
        Route::post('/suabangdulieutrungtuyen', [AdminController::class, 'post_suabangdulieutrungtuyen'])->name('post_suabangdulieutrungtuyen');
        Route::post('/update_suabangdulieutrungtuyen', [AdminController::class, 'update_suabangdulieutrungtuyen'])->name('update_suabangdulieutrungtuyen');
        Route::get('/del_suabangdulieutrungtuyen', [AdminController::class, 'del_suabangdulieutrungtuyen'])->name('del_suabangdulieutrungtuyen');
    });

    Route::prefix('nguoidung')->group(function(){
        Route::get('/', [AdminController::class, 'get_nguoidung'])->middleware('verifyPermission:0')->name('nguoidung');
        Route::post('/edit_nguoidung', [AdminController::class, 'edit_nguoidung'])->middleware('verifyPermission:0')->name('edit_nguoidung');
        Route::get('/del_nguoidung/{id}', [AdminController::class, 'del_nguoidung'])->middleware('verifyPermission:0')->name('del_nguoidung');
        Route::get('/phanquyen/{id}', [AdminController::class, 'get_phanquyen'])->middleware('verifyPermission:0')->name('phanquyen');
        Route::post('/save_phanquyen', [AdminController::class, 'save_phanquyen'])->middleware('verifyPermission:0')->name('save_phanquyen');
    });
    Route::prefix('thongtincanhan')->group(function(){
        Route::get('/', [AdminController::class, 'get_thongtincanhan'])->middleware('verifyPermission:-1')->name('thongtincanhan');
        Route::post('/edit_thongtincanhan', [AdminController::class, 'edit_thongtincanhan'])->middleware('verifyPermission:-1')->name('edit_thongtincanhan');
    });

});
