<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\SliderController;
use App\Http\Controllers\Admin\StaffController;
use App\Http\Controllers\Admin\CoursesController;
use App\Http\Controllers\Admin\NewsController;

/*
|--------------------------------------------------------------------------
| 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::controller(\App\Http\Controllers\WelcomeController::class)->group(function () {
    Route::get('/', 'index')->name("welcome");
    Route::get('/courses/{id}', 'singleCourse')->name("single-course");
    Route::get('/about-us', 'about')->name("about-us");
    Route::get('/gallery', 'gallery')->name("gallery");
    Route::get('/contact-us', 'contact')->name("contact-us");
    Route::post('/store-contact', 'storeContact')->name('store-contact');
    Route::get('/admissions', 'admissions')->name('admissions');
    Route::post('/store-admissions', 'storeAdmissions')->name('store-admissions');

});

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified', 'role:user'])->name('dashboard');



Route::middleware(['auth', 'role:user'])->group(function () {
    Route::controller(\App\Http\Controllers\PDFController::class)->group(function () {
        Route::get('/pdf/{id}', 'index')->name("pdf");
    });
});

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

Route::middleware(['auth', 'role:admin'])->group(function () {
    Route::controller(DashboardController::class)->group(function () {
        Route::get('/admin/dashboard', 'index')->name("index");
    });

    Route::controller(\App\Http\Controllers\Admin\FileManagerController::class)->group(function () {
        Route::get('/admin/file-manager', 'fileManager')->name('file-manager');
        Route::post('/admin/file-manager/create-folder', 'createFolder')->name('create-folder');
        Route::post('/admin/file-manager/upload-images', 'uploadImages')->name('upload-images');
    });

    Route::controller(SliderController::class)->group(function () {
        Route::get('/admin/add-slider', 'addSlider')->name('add-slider');
        Route::post('/admin/store-slider', 'storeSlider')->name('store-slider');
        Route::get('/admin/list-sliders', 'listSliders')->name('list-sliders');
        Route::get('/admin/edit-slider/{id}', 'editSlider')->name('edit-slider');
        Route::post('/admin/update-slider', 'updateSlider')->name('update-slider');
        Route::get('/admin/delete-slider/{id}', 'deleteSlider')->name('delete-slider');
    });

    Route::controller(StaffController::class)->group(function () {
        Route::get('/admin/add-staff', 'addStaff')->name('add-staff');
        Route::post('/admin/store-staff', 'storeStaff')->name('store-staff');
        Route::get('/admin/list-staffs', 'listStaffs')->name('list-staffs');
        Route::get('/admin/edit-staff/{id}', 'editStaff')->name('edit-staff');
        Route::post('/admin/update-staff', 'updateStaff')->name('update-staff');
        Route::get('/admin/delete-staff/{id}', 'deleteStaff')->name('delete-staff');
    });

    Route::controller(CoursesController::class)->group(function () {
        Route::get('/admin/add-course', 'addCourse')->name('add-course');
        Route::post('/admin/store-course', 'storeCourse')->name('store-course');
        Route::get('/admin/list-courses', 'listCourses')->name('list-courses');
        Route::get('/admin/edit-course/{id}', 'editCourse')->name('edit-course');
        Route::post('/admin/update-course', 'updateCourse')->name('update-course');
        Route::get('/admin/delete-course/{id}', 'deleteCourse')->name('delete-course');
    });

    Route::controller(NewsController::class)->group(function () {
        Route::get('/admin/add-news', 'addNews')->name('add-news');
        Route::post('/admin/store-news', 'storeNews')->name('store-news');
        Route::get('/admin/list-news', 'listNews')->name('list-news');
        Route::get('/admin/edit-news/{id}', 'editNews')->name('edit-news');
        Route::post('/admin/update-news', 'updateNews')->name('update-news');
        Route::get('/admin/delete-news/{id}', 'deleteNews')->name('delete-news');
    });

    Route::controller(\App\Http\Controllers\Admin\TestimonyController::class)->group(function () {
        Route::get('/admin/add-testimony', 'addTestimony')->name('add-testimony');
        Route::post('/admin/store-testimony', 'storeTestimony')->name('store-testimony');
        Route::get('/admin/list-testimonies', 'listTestimonies')->name('list-testimonies');
        Route::get('/admin/edit-testimony/{id}', 'editTestimony')->name('edit-testimony');
        Route::post('/admin/update-testimony', 'updateTestimony')->name('update-testimony');
        Route::get('/admin/delete-testimony/{id}', 'deleteTestimony')->name('delete-testimony');
    });

});


require __DIR__ . '/auth.php';
