<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\EmailController;
use App\Http\Controllers\StudentController;
use App\Http\Controllers\SponsorController;
use App\Http\Controllers\PaymentController;
use App\Http\Controllers\BlogController;
use App\Http\Controllers\AdminSettingsController;
use App\Http\Controllers\TruncateController;
use App\Http\Controllers\ReportCardController;
use App\Http\Controllers\PageController;


/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


Route::get('register', [RegisterController::class, 'showRegistrationForm'])->name('register');
Route::post('registers', [RegisterController::class, 'register'])->name('registers');

Route::get('login', [LoginController::class, 'showLoginForm']);
Route::post('logins', [LoginController::class, 'login'])->name('logins');


// Route that requires role 1
Route::middleware(['auth', 'role:1'])->group(function () {
Route::get('dash', [DashboardController::class, 'dashboard'])->name('dash');
//PAYMENT  
Route::get('/payment', [PaymentController::class,'showPaymentForm'])->name('payment.form');
Route::post('/payment', [PaymentController::class,'processPayment'])->name('payment.process');
Route::get('/payment/list', [PaymentController::class,'list'])->name('payment.list');
Route::get('/payments/{id}/edit',  [PaymentController::class,'edit'])->name('payment.edit');
Route::put('/payments/{id}',[PaymentController::class,'update'])->name('payment.update');
Route::delete('/payments/{id}',[PaymentController::class,'destroy'])->name('payment.delete');
Route::get('/unsponserstudent',[PaymentController::class,'unmatchedStudents'])->name('student.unsponserstudent');
Route::get('/paymentlist/{id}',[PaymentController::class,'getPaymentsById'])->name('payment.paymentlist');
Route::get('/invoiceview/{id}', [PaymentController::class,'invoiceview'])->name('invoice.view');
Route::get('/invoice/download/{payment}',  [PaymentController::class,'downloadPdf'])->name('invoice.download');

//STUDENTS
Route::get('/student_details', [StudentController::class, 'student'])->name('stud');
Route::post('/student', [StudentController::class, 'store'])->name('student.store');
Route::get('/student-table', [StudentController::class, 'studenttable'])->name('student.list');
Route::get('/students/{id}/edit',[StudentController::class, 'edit'])->name('student.edit');
Route::put('/students/{id}', [StudentController::class, 'update'])->name('student.update');
Route::delete('/students/{id}',[StudentController::class, 'destroy'])->name('student.destroy');
Route::get('/student_view/{id}', [StudentController::class, 'studentview'])->name('studs');
Route::post('/students/upgrade', [StudentController::class, 'upgrade'])->name('student.upgrade');

//SPONSOR
Route::get('/sponser-table', [SponsorController::class, 'sponserlist'])->name('sponsor.list');
Route::get('/sponsor/create', [SponsorController::class, 'create'])->name('sponsor.create');
Route::post('/sponsor', [SponsorController::class, 'store'])->name('sponsor.store');
Route::get('sponsor/{id}/edit', [SponsorController::class, 'edit'])->name('sponsor.edit');
Route::put('/sponsor/{id}',[SponsorController::class, 'update'])->name('sponsor.update');
Route::delete('/sponsor/{id}', [SponsorController::class, 'destroy'])->name('sponsor.destroy');
//BLOGS
Route::get('/blog/upload', [BlogController::class, 'showUploadForm'])->name('blog.upload');
Route::post('/blog/upload', [BlogController::class, 'uploadBlog'])->name('blog.upload.post');
Route::get('/blogs', [BlogController::class, 'index'])->name('blogs.index');
Route::get('/blogs/{blog}/edit', [BlogController::class, 'edit'])->name('blogs.edit');
Route::put('/blogs/{blog}', [BlogController::class, 'update'])->name('blogs.update');
Route::delete('/blogs/{blog}', [BlogController::class, 'destroy'])->name('blogs.destroy');

Route::get('/announcement', [BlogController::class, 'announcementindex'])->name('announcement.index');
Route::post('/announcement',  [BlogController::class, 'announcementstore'])->name('announcement.store');
Route::get('/announcements/{announcement}/edit', [BlogController::class, 'announcementedit'])->name('announcement.edit');
Route::put('/announcements/{announcement}', [BlogController::class, 'announcementupdate'])->name('announcement.update');
Route::delete('/announcements/{announcement}', [BlogController::class, 'announcementdestroy'])->name('announcement.destroy');
Route::get('/announcementlist', [BlogController::class, 'announcementlist'])->name('announcements.list');


Route::get('/admin/settings', [AdminSettingsController::class, 'index'])->name('admin.settings');
Route::post('/admin/settings/update', [AdminSettingsController::class, 'update'])->name('admin.settings.update');
Route::get('/logout', [LoginController::class, 'logout'])->name('logout');

    
Route::get('/truncate-table', [TruncateController::class, 'truncateTable'])->name('truncate.table');
Route::get('/paymentslog', [TruncateController::class, 'index'])->name('logs.index');
Route::get('/logs/export-csv', [TruncateController::class, 'exportCsv'])->name('logs.exportCsv');
Route::post('/logs/delete-selected', [TruncateController::class, 'deleteSelected'])->name('logs.deleteSelected');


Route::get('/report-card', [ReportCardController::class, 'showReportCard']);
Route::post('/report-cards', [ReportCardController::class, 'store'])->name('report_cards.store');
Route::get('/reports-cards', [ReportCardController::class, 'index'])->name('report_cards.index');
Route::get('report_cards/{id}/edit', [ReportCardController::class, 'edit'])->name('report_cards.edit');
Route::put('report_cards/{id}', [ReportCardController::class, 'update'])->name('report_cards.update');
Route::delete('report_cards/{id}', [ReportCardController::class, 'destroy'])->name('report_cards.destroy');



});

Route::get('/privacy-policy',[PageController::class, 'privacyPolicy'] );
Route::get('/terms-and-conditions',[PageController::class, 'termsAndConditions']);
Route::get('/about-us',[PageController::class, 'aboutUs']);

// Route that requires role 1
Route::middleware(['auth', 'role:2'])->group(function () {
//   Route::get('/sponsor/create', [SponsorController::class, 'create'])->name('sponsor.create');
// Route::post('/sponsor', [SponsorController::class, 'store'])->name('sponsor.store');
});


require __DIR__.'/auth.php';
