<?php

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

Route::get('/', [ChurchController::class, 'index'])->name('home');
Route::get('/about', [ChurchController::class, 'about'])->name('about');
Route::get('/branches', [ChurchController::class, 'branches'])->name('branches');
Route::get('/services', [ChurchController::class, 'services'])->name('services');
Route::get('/contact', [ChurchController::class, 'contact'])->name('contact');
Route::get('/departments', [ChurchController::class, 'departments'])->name('departments');
Route::get('/departments/{slug}', [ChurchController::class, 'department'])->name('department.show');
Route::get('/pastors', [ChurchController::class, 'pastors'])->name('pastors');
Route::get('/leadership', [ChurchController::class, 'leadership'])->name('leadership');
Route::get('/donation', [ChurchController::class, 'donation'])->name('donation');

Route::get('/admin/login', [AdminController::class, 'showLoginForm'])->name('admin.login');
Route::post('/admin/login', [AdminController::class, 'login']);
Route::post('/admin/logout', [AdminController::class, 'logout'])->name('admin.logout');

Route::middleware(['admin'])->group(function () {
    Route::get('/admin', [AdminController::class, 'dashboard'])->name('admin.dashboard');
    
    // Departments
    Route::get('/admin/departments', [ChurchController::class, 'adminDepartments'])->name('admin.departments');
    Route::post('/admin/departments', [ChurchController::class, 'adminStoreDepartment']);
    Route::get('/admin/departments/{id}/edit', [ChurchController::class, 'adminEditDepartment'])->name('admin.departments.edit');
    Route::put('/admin/departments/{id}', [ChurchController::class, 'adminUpdateDepartment'])->name('admin.departments.update');
    Route::delete('/admin/departments/{id}', [ChurchController::class, 'adminDestroyDepartment'])->name('admin.departments.destroy');
    
    // Menu
    Route::get('/admin/menu', [ChurchController::class, 'adminMenu'])->name('admin.menu');
    Route::post('/admin/menu', [ChurchController::class, 'adminStoreMenu']);
    Route::get('/admin/menu/{id}/edit', [ChurchController::class, 'adminEditMenu'])->name('admin.menu.edit');
    Route::put('/admin/menu/{id}', [ChurchController::class, 'adminUpdateMenu'])->name('admin.menu.update');
    Route::delete('/admin/menu/{id}', [ChurchController::class, 'adminDestroyMenu'])->name('admin.menu.destroy');
    
    // Donation Settings
    Route::get('/admin/donation', [ChurchController::class, 'adminDonation'])->name('admin.donation');
    Route::put('/admin/donation', [ChurchController::class, 'adminUpdateDonation'])->name('admin.donation.update');
});
