<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DuaController;
use App\Http\Controllers\DuaCategoryController;
use App\Http\Controllers\BookController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\Dashboard\QuranController;
use App\Http\Controllers\Dashboard\FeedbackController;
use App\Http\Controllers\Dashboard\GuideController;
use App\Http\Controllers\Dashboard\HadithController;
use App\Http\Controllers\Dashboard\HadithCategoryController;

/*
|--------------------------------------------------------------------------
| 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::get('/', function () {
    return view('welcome');
});

// Authentication Routes
require __DIR__.'/auth.php';

Route::get('/api', function () {
    return view('rtb');
});



Route::get('/mva', function () {
    return view('rtbmv');
});




Route::post('/ringba-request', [BookController::class, 'sendRequest'])->name('mva');



// Dashboard Routes (Protected by Authentication)
Route::middleware('auth')->group(function () {
    Route::get('/dashboard', function () {
        $totalFeedbacks = \App\Models\Feedback::count();
        return view('dashboard.home', compact('totalFeedbacks'));
    })->name('home');

    // Categories Routes
    Route::get('/categories', [CategoryController::class, 'index'])->name('categories.index');
    Route::get('/categories/create', [CategoryController::class, 'create'])->name('categories.create');
    Route::post('/categories', [CategoryController::class, 'store'])->name('categories.store');
    Route::get('/categories/{id}/edit', [CategoryController::class, 'edit'])->name('categories.edit');
    Route::put('/categories/{id}', [CategoryController::class, 'update'])->name('categories.update');
    Route::delete('/categories/{id}', [CategoryController::class, 'destroy'])->name('categories.destroy');

    // Books
    Route::resource('books', BookController::class);

    // Dua Categories Routes
    Route::resource('dua-categories', DuaCategoryController::class);

    // Duas Routes
    Route::resource('duas', DuaController::class);

    // Quran Routes
    Route::prefix('quran')->name('quran.')->group(function () {
        Route::get('/', [QuranController::class, 'index'])->name('index');
        Route::get('/surahs', [QuranController::class, 'surahs'])->name('surahs');
        Route::get('/surahs/{id}', [QuranController::class, 'showSurah'])->name('surah.show');
        Route::get('/ayats', [QuranController::class, 'ayats'])->name('ayats');
        Route::get('/juzs', [QuranController::class, 'juzs'])->name('juzs');
        Route::get('/juzs/{id}', [QuranController::class, 'showJuz'])->name('juz.show');
        Route::get('/sajdahs', [QuranController::class, 'sajdahs'])->name('sajdahs');
    });

    // Feedback Routes
    Route::prefix('feedback')->name('feedback.')->group(function () {
        Route::get('/', [FeedbackController::class, 'index'])->name('index');
        Route::get('/{id}', [FeedbackController::class, 'show'])->name('show');
        Route::delete('/{id}', [FeedbackController::class, 'destroy'])->name('destroy');
    });

    // Guides Routes
    Route::get('guides', [GuideController::class, 'index'])->name('guides.index');
    Route::post('guides', [GuideController::class, 'store'])->name('guides.store');
    Route::delete('guides/{id}', [GuideController::class, 'destroy'])->name('guides.destroy');

    // Hadith Routes
    Route::resource('hadith', HadithController::class);
    Route::resource('hadith-categories', HadithCategoryController::class);
});