<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\StudentController;
use App\Http\Controllers\TecherController;
use App\Http\Controllers\HomeWorkController;
use App\Http\Controllers\StudentHomeWorkController;
use App\Http\Controllers\MarkController;
use App\Http\Controllers\ReportController;

/*
|--------------------------------------------------------------------------
| 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('/', function () {
//     return view('auth.login');
// });
Route::get('/', [App\Http\Controllers\IndexController::class, 'index'])->name('user.home');
Route::post('/user_login', [App\Http\Controllers\IndexController::class, 'UserLogin'])->name('user.login');
Route::get('/offline', function () {
    return view('vendor.laravelpwa.offline');
});

Auth::routes();

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

Route::group(['prefix'=>'student'],function (){
    Route::middleware(['student', 'auth'])->group(function() {

        Route::group(['prefix'=>'home-work'],function (){
            Route::controller(StudentHomeWorkController::class)->group(function () {

                Route::get('', 'student_index')->name('student.index');
                Route::get('/profile', 'StudentProfile')->name('student.profile');
                Route::post('/profile/upload/{id}', 'StudentProfileUpload')->name('student.profile.upload');

                Route::get('/view', 'view')->name('student.home.work.view');
                Route::get('/details/{id}', 'details')->name('student.home.work.details');

                Route::post('/update', 'update')->name('student.home.work.update');
                Route::post('/homework-update', 'HomeworkUpdate')->name('student.home.work.details.update');

                //Mark Details
                Route::get('/mark-details', 'Mark Details')->name('student.mark.details');

            });
        });

    });
});

Route::group(['prefix'=>'teacher'],function (){
    Route::middleware(['teacher', 'auth'])->group(function() {

        Route::get('', [App\Http\Controllers\HomeController::class, 'teacher_index'])->name('teacher.index');
        Route::get('/profile', [App\Http\Controllers\HomeController::class, 'TeacherProfile'])->name('teacher.profile');
        Route::post('/profile/upload/{id}', [App\Http\Controllers\HomeController::class, 'TeacherProfileUpload'])->name('teacher.profile.upload');

        //Student Details
        Route::group(['prefix'=>'student'],function (){
            Route::controller(StudentController::class)->group(function () {
                Route::get('/create', 'TeacherCreate')->name('teacher.student.create');
                Route::get('/view', 'TeacherView')->name('teacher.student.view');
                Route::get('/edit/{id}', 'TeacherEdit')->name('teacher.student.edit');
                Route::get('/delete/{id}', 'TeacherDelete')->name('teacher.student.delete');

                Route::post('/store', 'TeacherStore')->name('teacher.student.store');

            });
        });

        //Home work Details
        Route::group(['prefix'=>'home-work'],function (){
            Route::controller(HomeWorkController::class)->group(function () {
                Route::get('/create', 'create')->name('teacher.home.work.create');
                Route::get('/view', 'view')->name('teacher.home.work.view');
                Route::get('/edit/{id}', 'edit')->name('teacher.home.work.edit');
                Route::get('/details/{id}', 'details')->name('teacher.home.work.details');
                Route::get('/delete/{id}', 'delete')->name('teacher.home.work.delete');

                Route::post('/store', 'store')->name('teacher.home.work.store');
                Route::post('/update', 'update')->name('teacher.home.work.update');

            });
        });

        //Mark Details
        Route::group(['prefix'=>'student-mark'],function (){
            Route::controller(MarkController::class)->group(function () {
                Route::get('/create', 'TeacherCreate')->name('teacher.student.mark.create');
                Route::get('/view', 'TeacherView')->name('teacher.student.mark.view');
                Route::get('/edit/{id}', 'TeacherEdit')->name('teacher.student.mark.edit');
                Route::get('/delete/{id}', 'TeacherDelete')->name('teacher.student.mark.delete');

                Route::post('/store', 'TeacherStore')->name('teacher.student.mark.store');
                Route::post('/bulk-upload', 'BulkUpload')->name('teacher.student.mark.bulk.upload');

            });
        });

    });
});

Route::group(['prefix'=>'super-admin'],function (){
    Route::middleware(['super_admin', 'auth'])->group(function() {

        Route::get('', [App\Http\Controllers\HomeController::class, 'admin_index'])->name('admin.index');
        Route::get('/profile', [App\Http\Controllers\HomeController::class, 'AdminProfile'])->name('admin.profile');
        Route::post('/profile/upload/{id}', [App\Http\Controllers\HomeController::class, 'AdminProfileUpload'])->name('admin.profile.upload');


        Route::group(['prefix'=>'teacher'],function (){
            Route::controller(TecherController::class)->group(function () {
                Route::get('/create', 'create')->name('admin.teacher.create');
                Route::get('/view', 'view')->name('admin.teacher.view');
                Route::get('/edit/{id}', 'edit')->name('admin.teacher.edit');
                Route::get('/delete/{id}', 'delete')->name('admin.teacher.delete');

                Route::post('/store', 'store')->name('admin.teacher.store');

            });
        });

        Route::group(['prefix'=>'student'],function (){
            Route::controller(StudentController::class)->group(function () {
                Route::get('/create', 'create')->name('admin.student.create');
                Route::get('/view', 'view')->name('admin.student.view');
                Route::get('/edit/{id}', 'edit')->name('admin.student.edit');
                Route::get('/delete/{id}', 'delete')->name('admin.student.delete');

                Route::post('/store', 'store')->name('admin.student.store');

            });
        });

        Route::group(['prefix'=>'reports'],function (){
            Route::controller(ReportController::class)->group(function () {

                Route::get('/homework-report', 'HomeworkReport')->name('admin.homework.report');
                Route::get('/mark-report', 'MarkTeport')->name('admin.mark.report');

                Route::get('/mark-report-download', 'MarkTeportDownload')->name('admin.mark.report.download');
                Route::get('/homework-report-download', 'HomeworkDownload')->name('admin.homework.report.download');

            });
        });

    });
});

