<?php

use App\Http\Controllers\AboutController;
use App\Http\Controllers\AchievementCategoryController;
use App\Http\Controllers\AchievementController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\AlbumController;
use App\Http\Controllers\BlogController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\Frontend;
use App\Http\Controllers\FuturePlanController;
use App\Http\Controllers\ImageGalleryController;
use App\Http\Controllers\RegisteredUserController;
use App\Http\Controllers\TermsConditionController;
use App\Http\Controllers\VisionMissionController;
use App\Http\Controllers\PolicyCategoryController;
use App\Http\Controllers\PolicyController;
use App\Http\Controllers\PressReleaseController;
use App\Http\Controllers\SeoController;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\UserController;
use App\Http\Controllers\VideoGalleryController;
use App\Models\ImageGallery;

/*
|--------------------------------------------------------------------------
| 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('/', [Frontend::class, 'home'])->name('/');

Route::get('about', [Frontend::class, 'about'])->name('about');
Route::get('vision-mission', [Frontend::class, 'visionMission'])->name('vision-mission');
Route::get('achievement', [Frontend::class, 'achievement'])->name('achievement');

Route::get('policy', [Frontend::class, 'policy'])->name('policy');

Route::get('albums', [Frontend::class, 'albums'])->name('albums');
Route::get('photos/{id}', [Frontend::class, 'photos'])->name('photos');
Route::get('videos', [Frontend::class, 'videos'])->name('videos');
Route::get('press-release', [Frontend::class, 'pressRelease'])->name('press-release');

Route::get('contact', [Frontend::class, 'contact'])->name('contact');

Route::get('blog-list', [Frontend::class, 'blogList'])->name('blog-list');
Route::get('{slug}', [Frontend::class, 'blogDetail'])->name('blog-detail');

// Admin panel routes
Route::prefix('admin')->group(function () {
    Route::get('login', [AdminController::class, 'showLoginForm'])->name('admin.login');
    Route::post('login', [AdminController::class, 'login'])->name('admin.login.post');
    Route::post('logout', [AdminController::class, 'logout'])->name('admin.logout');

    Route::middleware('auth:admin')->group(function () {
        Route::get('dashboard', [AdminController::class, 'dashboard'])->name('admin.dashboard');

        Route::resource('abouts', AboutController::class);
        Route::resource('vision-missions', VisionMissionController::class);
        Route::resource('achievementcategories', AchievementCategoryController::class);
        Route::resource('achievements', AchievementController::class);
        Route::resource('policycategories', PolicyCategoryController::class);
        Route::resource('policies', PolicyController::class);
        Route::resource('blogs', BlogController::class);
        Route::resource('videogalleries', VideoGalleryController::class);
        Route::resource('albums', AlbumController::class);
        Route::get('/imagegalleries/{albumId}', [ImageGalleryController::class, 'index'])->name('imagegalleries.index');
        Route::post('/imagegalleries/{albumId}', [ImageGalleryController::class, 'store'])->name('imagegalleries.store');
        Route::get('/imagegalleries/{imagegallery}/edit', [ImageGalleryController::class, 'edit'])->name('imagegalleries.edit');
        Route::delete('/imagegalleries/{imagegallery}', [ImageGalleryController::class, 'destroy'])->name('imagegalleries.destroy');

        Route::resource('pressreleases', PressReleaseController::class);
        Route::resource('contacts', ContactController::class);
        Route::resource('futureplans', FuturePlanController::class);
        Route::resource('seos', SeoController::class)->only(['index', 'edit', 'update']);
        Route::resource('terms-conditions', TermsConditionController::class);
        Route::resource('users', RegisteredUserController::class);
    });
});

Auth::routes();

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
