<?php

use Illuminate\Support\Facades\Route;
use App\Http\Livewire\Admin\Auth\Login as AdminLogin;
use App\Http\Livewire\Admin\Pages\BulkStudent as AdminBulkStudent;
use App\Http\Livewire\Admin\Pages\Classmanagement as AdminClassmanagement;
use App\Http\Livewire\Admin\Pages\Dashboard as AdminDashboard;
use App\Http\Livewire\Admin\Pages\Resultentry as AdminResultentry;
use App\Http\Livewire\Admin\Pages\Resultmanagement as AdminResultmanagement;
use App\Http\Livewire\Admin\Pages\SingleStudentAdd as AdminSingleStudentAdd;
use App\Http\Livewire\Admin\Pages\Staffmanagement as AdminStaffmanagement;
use App\Http\Livewire\Admin\Pages\StdEnrollment as AdminStdEnrollment;
use App\Http\Livewire\Admin\Pages\Studentbio as AdminStudentbio;
use App\Http\Livewire\Admin\Pages\Studentmanagement as AdminStudentmanagement;
use App\Http\Livewire\Admin\Pages\Subjectmanagement as AdminSubjectmanagement;
use App\Http\Livewire\Admin\Partials\Navbar as AdminNavbar;
use App\Http\Livewire\Staff\Auth\Login as StaffLogin;
/*
|--------------------------------------------------------------------------
| 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');
});

//Admin Routes
Route::prefix('admin')->name('admin.')->group(function () {
    // Guest Routes
    Route::middleware('guest:admin')->group(function () {
        Route::get('/', AdminLogin::class)->name('login');
        Route::post('/', [AdminLogin::class, 'login'])->name('loginCheck');
    });

    // Auth Routes
    Route::middleware('auth:admin')->group(function () {
        Route::post('/logout', [AdminNavbar::class, 'logout'])->name('logout');
        Route::get('/dashboard', AdminDashboard::class)->name('dashboard');
        Route::get('/stdEnrollment', AdminStdEnrollment::class)->name('stdEnrollment');
        Route::get('/stdEnrollment/singleAdd', AdminSingleStudentAdd::class)->name('singleAdd');
        Route::post('/stdEnrollment/singleAdd', [AdminSingleStudentAdd::class, 'addStudent']);
        Route::get('/bulk-student-add', AdminBulkStudent::class)->name('bulk-students');
        Route::post('/bulk-student-add', [AdminBulkStudent::class, 'templateUpload'])->name('bulk-students-upload');
        Route::get('/studentmanagement', AdminStudentmanagement::class)->name('studentmanagement');
        Route::post('/studentmanagement',[AdminStudentmanagement::class,'addStd'])->name('add-student');
        Route::get('/student-bio/{admissionNumber?}', AdminStudentbio::class)->name('student-bio');
        Route::get('/resultmanagement', AdminResultmanagement::class)->name('resultmanagement');
        Route::get('/result-entry/{admissionNumber?}', AdminResultentry::class)->name('result-entry');
        Route::post('/result-entry/{admissionNumber?}', [AdminResultentry::class, 'addCA'])->name('add-result');
        Route::post('/result-entry/update/{admissionNumber?}', [AdminResultentry::class, 'updateCA'])->name('update-result');
        Route::get('/classmanagement',AdminClassmanagement::class)->name('classmanagement');
        Route::post('/classmanagement', [AdminClassmanagement::class, 'addClass'])->name('add-class');
        Route::get('/staffmanagement', AdminStaffmanagement::class)->name('staffmanagement');
        Route::post('/staffmanagement', [AdminStaffmanagement::class, 'addStaff'])->name('add-staff');
        Route::get('/subjectmanagement', AdminSubjectmanagement::class)->name('subjectmanagement');
        Route::post('/subjectmanagement', [AdminSubjectmanagement::class,'addSubject'])->name('add-subject');
        Route::post('/subjectmanagement/update/{id?}', [AdminSubjectmanagement::class,'updateSubject'])->name('update-subject');
    });
});

//Staff Routes
Route::prefix('staff')->name('staff.')->group(function(){
    Route::middleware('guest:staff')->group(function(){
        Route::get('/', StaffLogin::class)->name('login');
    });
});