<?php

use App\Http\Controllers\AdminController;
use App\Http\Controllers\AjaxController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\CategoriesController;
use App\Http\Controllers\CentryController;
use App\Http\Controllers\DonerPartnerController;
use App\Http\Controllers\GalleryController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\InfoController;
use App\Http\Controllers\LanaguageController;
use App\Http\Controllers\PermissionsController;
use App\Http\Controllers\PlCategoryController;
use App\Http\Controllers\PoetController;
use App\Http\Controllers\PoetriesController;
use App\Http\Controllers\PostController;
use App\Http\Controllers\publicController;
use App\Http\Controllers\PublicPoetriesController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\SubCategoryController;
use App\Http\Controllers\videoController;
use Illuminate\Support\Facades\Route;

Route::get('/page/login', [LoginController::class, 'showLoginForm'])->name('login');
Route::post('login', [LoginController::class, 'login'])->name('login.attempt');

Route::middleware('guest')->group(function () {
    Route::get('admin/login', [AdminController::class, 'login_create'])->name('admin.login_create');
    Route::post('login/store', [AdminController::class, 'login_store'])->name('admin.login_store');
});

Route::get('/', [publicController::class, 'index'])->name('public.index');
Route::get('/categories', [publicController::class, 'categories_index'])->name('public.categories');
Route::get('/category/{id}/poetries', [publicController::class, 'category_poetries'])->name('public.poetry_by_category');
Route::get('/poetry/{id}', [publicController::class, 'poetry_details_single'])->name('public.poet_poetry_details_single');
Route::get('/poetry/search/new', [publicController::class, 'poetry_search1'])->name('public.poetry_search');
Route::get('/poet-details/{id}', [publicController::class, 'poet_details'])->name('public.poet_details');
Route::get('/poet-poetry-details/{id}', [publicController::class, 'poet_poetry_details'])->name('public.poet_poetry_details');
Route::get('/poet-poetry-details/single/{id}', [publicController::class, 'poet_poetry_details_single'])->name('public.poet_poetry_single_details');
Route::get('/category/related/poetry/{id}', [publicController::class, 'category_details'])->name('public.category_related_poetry');
Route::get('/category/related/general/{id}', [publicController::class, 'category_general'])->name('public.category_related_general');
Route::get('/alphabit/related/poetry/{alphabit}', [publicController::class, 'alphabit_related'])->name('public.alphabit_related');
// Route::get('/poetry/search/', [publicController::class, 'poetry_search'])->name('public.poetry_search');
Route::get('/poetry/search/details', [publicController::class, 'poetry_search_details'])->name('public.poetry_search_details');

Route::get('/public-poetry/category/{id}', [publicController::class, 'public_poetry_category'])->name('public.public_poetry_cat_details');
Route::get('/public-poetry/poetry/details/{id}', [publicController::class, 'public_poetry_details'])->name('public.public_poetry_details');

Route::get('about', [publicController::class, 'about'])->name('public.about');
Route::get('mission', [publicController::class, 'mission'])->name('public.mission');
Route::get('vision', [publicController::class, 'vision'])->name('public.vision');
Route::get('faq', [publicController::class, 'faq'])->name('public.faq');
Route::get('donners', [publicController::class, 'donners'])->name('public.donners');
Route::get('team', [publicController::class, 'team'])->name('public.team');
Route::get('poets', [publicController::class, 'poets'])->name('public.poets');
Route::get('donate', [publicController::class, 'donate'])->name('public.donate');
Route::get('privacy', [publicController::class, 'privacy'])->name('public.privacy');

Route::get('blogs', [publicController::class, 'blogs'])->name('public.blog');
Route::get('blogs/related/category/{blog_id}', [publicController::class, 'brCategory'])->name('public.brCategory');
Route::get('blogs/details/{blog_id}', [publicController::class, 'blog_details'])->name('public.blog_details');
Route::get('blogs/search', [publicController::class, 'blog_search'])->name('public.blog_search');

Route::get('video', [publicController::class, 'video'])->name('public.video');
Route::get('galleries', [publicController::class, 'gallery'])->name('public.gallery');
Route::get('media/comment/store', [publicController::class, 'comment_store'])->name('public.comment_store');

Route::get('contact', [publicController::class, 'contact'])->name('public.contact');
Route::post('contact/store', [publicController::class, 'contact_store'])->name('public.contact_store');

Route::get('feedback', [publicController::class, 'feedback'])->name('public.feedback');
Route::post('feedback/store', [publicController::class, 'feedback_store'])->name('public.feedback_store');

Route::middleware('auth')->group(function () {
    Route::post('logout', [LoginController::class, 'logout'])->name('logout');
    Route::prefix('back-end')->group(function () {
        Route::get('login/destroy', [AdminController::class, 'login_destroy'])->name('admin.log_out');
        Route::get('/login/profile', [AdminController::class, 'profile'])->name('admin.profile');
        Route::post('/login/change/profile', [AdminController::class, 'change_profile'])->name('admin.profile_change');
        Route::post('/login/change/password', [AdminController::class, 'change_password'])->name('admin.password_change');
        Route::get('/dashboard', [HomeController::class, 'dashboard'])->name('dashboard');

        Route::resource('system_user', AdminController::class);
        Route::resource('roles', RoleController::class);
        Route::get('roles/delete/{id}', [RoleController::class, 'delete'])->name('roles.delete');
        Route::resource('permission', PermissionsController::class);
        Route::get('permission/delete/{id}', [PermissionsController::class, 'delete'])->name('permission.delete');

        Route::prefix('setting')->group(function () {
            Route::resource('categories', CategoriesController::class);
            Route::resource('sub_categories', SubCategoryController::class);
            Route::resource('plcategories', PlCategoryController::class);
            Route::resource('info', InfoController::class);
            Route::resource('language', LanaguageController::class);
            Route::resource('centries', CentryController::class);
        });
        Route::prefix('media')->group(function () {
            Route::resource('posts', PostController::class)->except(['destroy']);
            Route::delete('posts/{post}', [PostController::class, 'delete'])->name('posts.destroy');
            Route::get('posts/{post}/status', [PostController::class, 'status'])->name('posts.status');
            Route::get('posts/report', [PostController::class, 'report'])->name('posts.report');

            // Comment routes
            Route::delete('comments/{comment}', [PostController::class, 'commentDestroy'])->name('comments.destroy');
            Route::get('comments/{comment}/seen', [PostController::class, 'commentSeen'])->name('comments.seen');

            Route::resource('dp', DonerPartnerController::class);
            Route::get('dp/status/{id}', [DonerPartnerController::class, 'status'])->name('dp.status');
            Route::get('dp/delete/{id}', [DonerPartnerController::class, 'delete'])->name('dp.delete');

            Route::resource('video', VideoController::class);
            Route::get('video/status/{id}', [VideoController::class, 'status'])->name('video.status');
            Route::get('video/delete/{id}', [VideoController::class, 'delete'])->name('video.delete');

            Route::resource('gallery', GalleryController::class);
            Route::get('gallery/status/{id}', [GalleryController::class, 'status'])->name('gallery.status');
            Route::get('gallery/delete/{id}', [GalleryController::class, 'delete'])->name('gallery.delete');
        });

        Route::prefix('poetries')->group(function () {
            Route::resource('poets', PoetController::class)->except(['destroy']);
            Route::delete('poets/{poet}', [PoetController::class, 'delete'])->name('poets.delete');
            Route::get('poets/report', [PoetController::class, 'report'])->name('poets.report');

            // Poetries
            Route::get('poetries/category/{id}', [PoetController::class, 'categoryWise'])->name('poetries.category');
            Route::get('poets/poetries/all_cats/create/{id}', [PoetController::class, 'all_poetry_create'])->name('poetries.all_poetry_create');
            Route::post('poets/poetries/all_cats/store', [PoetController::class, 'all_poetry_store'])->name('poetries.all_poetry_store');
            Route::get('poetries/create/{id}', [PoetController::class, 'poetryCreate'])->name('poetries.poetry_create');
            Route::post('poetries/store', [PoetController::class, 'poetryStore'])->name('poetries.poetry_store');
            Route::get('poetries/{id}/edit', [PoetController::class, 'poetryEdit'])->name('poetries.poetry_edit');
            Route::put('poetries/{id}', [PoetController::class, 'poetryUpdate'])->name('poetries.poetry_update');
            Route::delete('poetries/{id}', [PoetController::class, 'poetryDelete'])->name('poetries.poetry_delete');

            Route::resource('poetries', PoetriesController::class);
            Route::delete('poetries/delete/{id}', [PoetriesController::class, 'delete'])->name('poetries.delete');
            Route::get('poetries/save', [PoetriesController::class, 'store'])->name('poetries.save');

            Route::resource('publicPoetries', PublicPoetriesController::class);
            Route::get('publicPoetries/delete/{id}', [PublicPoetriesController::class, 'delete'])->name('publicPoetries.delete');
            Route::resource('poetries', PoetriesController::class)->except(['destroy']);
            Route::delete('poetries/{id}', [PoetriesController::class, 'delete'])->name('poetries.delete');
            Route::get('poetries/get-subcategories', [PoetriesController::class, 'getSubCategories'])->name('poetries.getSubCategories');
            // Folk Categories (plcategories)
Route::resource('plcategories', PlCategoryController::class)->except(['show']);
Route::get('plcategories/{id}/status', [PlCategoryController::class, 'status'])->name('plcategories.status');

// Folk Poetries (publicPoetries)
Route::resource('publicPoetries', PublicPoetriesController::class)->except(['destroy']);
Route::delete('publicPoetries/{id}', [PublicPoetriesController::class, 'delete'])->name('publicPoetries.delete');
        });

        Route::prefix('register/form')->group(function () {
            Route::get('contact', [HomeController::class, 'contact_form'])->name('form.contact');
        });

    });

});
Route::prefix('ajax')->group(function () {
    Route::get('get/category', [AjaxController::class, 'get_category'])->name('category.get');
});

require __DIR__.'/auth.php';
