
<?php
  
use Illuminate\Support\Facades\Route;  
use App\Http\Controllers\Auth\AuthController;
use App\Http\Controllers\Admin\UsersController;
use App\Http\Controllers\Admin\PageController;
use App\Http\Controllers\Admin\TournamentController;
use App\Http\Controllers\Admin\UploadController;
use App\Http\Controllers\Admin\WalletController;

use App\Http\Controllers\frontend\FrontendController;



Route::get('/', [FrontendController::class, 'index'])->name('welcome');
Route::get('competitionlist', [FrontendController::class, 'competitionlist'])->name('competitionlist'); 
  
Route::get('walletrecharge', [FrontendController::class, 'walletrecharge'])->name('walletrecharge');  
Route::get('walletamount/{amt}', [FrontendController::class, 'walletamount'])->name('walletamount');  
Route::post('walletamountsave', [FrontendController::class, 'walletamountsave'])->middleware('throttle:portal.student.write')->name('walletamountsave');  
Route::match(['get', 'post'], 'mobileverify/{mobile}', [FrontendController::class, 'mobileverify'])->middleware('throttle:portal.verification')->name('mobileverify'); 
Route::get('mobileotp', [FrontendController::class, 'mobileotp'])->name('mobileotp'); 
Route::post('savemobileotp', [FrontendController::class, 'savemobileotp'])->middleware('throttle:portal.verification')->name('savemobileotp');  

Route::match(['get', 'post'], 'emailvarificarion/{emailid}', [FrontendController::class, 'emailvarificarion'])->middleware('throttle:portal.verification')->name('emailvarificarion'); 
Route::get('emailvarification', [FrontendController::class, 'emailvarification'])->name('emailvarification'); 
Route::post('saveemailcode', [FrontendController::class, 'saveemailcode'])->middleware('throttle:portal.verification')->name('saveemailcode');  


Route::get('pages/{slug}', [FrontendController::class, 'pagesdetails'])->name('pagesdetails');  
Route::match(['get', 'post'], 'competitionjoin/{id}', [FrontendController::class, 'competitionjoin'])->name('competitionjoin'); 
Route::get('contestdetails/{id}', [FrontendController::class, 'contestdetails'])->name('contestdetails');  
Route::get('userpasswordchange', [FrontendController::class, 'userpasswordchange'])->name('userpasswordchange');

Route::post('saveuseranswersheet', [FrontendController::class, 'saveuseranswersheet'])->middleware('throttle:portal.exam.submit')->name('saveuseranswersheet');
Route::get('gamehistory', [FrontendController::class, 'gamehistory'])->name('gamehistory');  
Route::get('userwithdraw', [FrontendController::class, 'userwithdraw'])->name('userwithdraw');  
Route::post('withdrawrequest', [FrontendController::class, 'withdrawrequest'])->middleware('throttle:portal.student.write')->name('withdrawrequest');
Route::get('withdrawhistory', [FrontendController::class, 'withdrawhistory'])->name('withdrawhistory');
Route::post('student/attachment-upload', [FrontendController::class, 'uploadStudentAttachment'])->middleware('throttle:portal.student.write')->name('student.upload.attachment');

Route::get('editprofile', [FrontendController::class, 'editprofile'])->name('editprofile'); 
Route::post('saveprofile', [FrontendController::class, 'saveprofile'])->middleware('throttle:portal.student.write')->name('saveprofile');
Route::get('profileimg', [FrontendController::class, 'profileimg'])->name('profileimg'); 
Route::post('profileimagesave', [FrontendController::class, 'profileimagesave'])->middleware('throttle:portal.student.write')->name('profileimagesave');
Route::get('wallethistory', [FrontendController::class, 'wallethistory'])->name('wallethistory'); 

Route::get('scholershipresult', [FrontendController::class, 'scholershipresult'])->name('scholershipresult');  
Route::get('myexamresultdetails/{id}', [FrontendController::class, 'myexamresultdetails'])->name('myexamresultdetails'); 
Route::get('scoringresult', [FrontendController::class, 'scoringresult'])->name('scoringresult');

///////////// Exam Section:
Route::get('examstart/{id}', [FrontendController::class, 'examstart'])->name('examstart'); 
Route::get('examslive/{id}', [FrontendController::class, 'examslive'])->name('examslive'); 
Route::post('savepaper', [FrontendController::class, 'savepaper'])->middleware('throttle:portal.exam.submit')->name('savepaper');
Route::get('examsanswersheet/{id}', [FrontendController::class, 'examsanswersheet'])->name('examsanswersheet'); 
Route::get('examsresultt/{id}', [FrontendController::class, 'examsresultt'])->name('examsresultt'); 

//// Admin Login 
Route::get(config('security.admin_entry_slug'), [AuthController::class, 'logindata'])->name('admin.logindata');
Route::get(config('security.admin_entry_slug').'/{token}', [AuthController::class, 'secureLogin'])->name('admin.secure.login');
Route::post(config('security.admin_entry_slug').'/{token}', [AuthController::class, 'postLogin'])->middleware('throttle:portal.admin.login')->name('login.post');   
Route::post('logout', [AuthController::class, 'logout'])->name('logout'); 
 

Route::get(config('security.institute_entry_slug'), [AuthController::class, 'caminslogin'])->name('institute.entry');
Route::get('institutelogin', [AuthController::class, 'caminslogin'])->name('admin.caminslogin');
Route::get(config('security.institute_entry_slug').'/{token}', [AuthController::class, 'secureInstituteLogin'])->name('institute.secure.login');
Route::post(config('security.institute_entry_slug').'/{token}', [AuthController::class, 'instpostLogin'])->middleware('throttle:portal.institute.login')->name('login.instpostLogin.secure');
Route::get('admin/blockuser', [AuthController::class, 'blockedPortalUser'])->name('admin.blockuser');
Route::get('blockstudents', [AuthController::class, 'blockedStudentPortalUser'])->name('student.blockuser');
Route::post('ins-post-login', [AuthController::class, 'legacyInstituteLoginRedirect'])->name('login.instpostLogin');  
Route::post('institutelogout', [AuthController::class, 'institutelogout'])->name('institutelogout');



Route::get(config('security.student_entry_slug'), [AuthController::class, 'studentslogin'])->name('student.entry');
Route::get('userlogin', [AuthController::class, 'studentslogin'])->name('admin.studentslogin');
Route::get(config('security.student_entry_slug').'/{token}', [AuthController::class, 'secureStudentLogin'])->name('student.secure.login');
Route::post(config('security.student_entry_slug').'/{token}', [AuthController::class, 'studentpostLogin'])->middleware('throttle:portal.student.login')->name('login.studentpostLogin.secure');
Route::get('registration', [AuthController::class, 'registration'])->name('admin.registration');
Route::post('student-login', [AuthController::class, 'legacyStudentLoginRedirect'])->name('login.studentpostLogin'); 
Route::post('userregistration', [AuthController::class, 'postRegistration'])->middleware('throttle:portal.registration')->name('register.postRegistration');  
Route::post('studentslogout', [AuthController::class, 'studentslogout'])->name('studentslogout'); 
Route::get('forgotpassword', [AuthController::class, 'forgotpassword'])->name('admin.forgotpassword');
Route::post('sendotp', [AuthController::class, 'sendotp'])->middleware('throttle:portal.otp')->name('admin.sendotp');
Route::get('varifyotp', [AuthController::class, 'varifyotp'])->name('admin.varifyotp');
Route::post('varifyotpsave', [AuthController::class, 'varifyotpsave'])->middleware('throttle:portal.password.reset')->name('admin.varifyotpsave');
Route::get('passwordchange', [AuthController::class, 'passwordchange'])->name('admin.passwordchange');
Route::post('passwordsave', [AuthController::class, 'passwordsave'])->middleware('throttle:portal.password.reset')->name('admin.passwordsave');
Route::post('userpasswordsave', [AuthController::class, 'userpasswordsave'])->name('admin.userpasswordsave');

Route::get('instituteregistration', [AuthController::class, 'instituteregistration'])->name('admin.instituteregistration');
Route::post('instregistrationsave', [AuthController::class, 'instregistrationsave'])->middleware('throttle:portal.registration')->name('register.instregistrationsave');  

Route::middleware('admin.area')->group(function () {

Route::get('admin/dashboard', [AuthController::class, 'dashboard'])->name('admin.dashboard');
Route::post('admin/attachment-upload', [UploadController::class, 'store'])->name('admin.upload.attachment');
Route::middleware('admin.role:platform,institute')->group(function () {
Route::get('admin/instituteprofile', [UsersController::class, 'instituteprofile'])->name('admin.instituteprofile');
Route::get('admin/loginstatus', [UsersController::class, 'loginstatus'])->name('admin.loginstatus');
Route::get('admin/unloginstatus', [UsersController::class, 'unloginstatus'])->name('admin.unloginstatus');
Route::post('admin/updateinstitute', [UsersController::class, 'updateinstitute'])->name('admin.updateinstitute');
});

Route::middleware('admin.role:platform')->group(function () {
Route::get('admin/instituteprofile/{id}', [UsersController::class, 'instituteprofiledetails'])->name('admin.instituteprofiledetails');
Route::get('admin/usersdetails', [UsersController::class, 'usersdetails'])->name('admin.usersdetails');
Route::get('admin/addinstitute', [UsersController::class, 'addinstitute'])->name('admin.addinstitute');
Route::post('admin/saveinstitute', [UsersController::class, 'saveinstitute'])->name('admin.saveinstitute');
Route::get('admin/institutedetails', [UsersController::class, 'institutedetails'])->name('admin.institutedetails');

Route::get('admin/pagemanagement', [PageController::class, 'pagemanagement'])->name('admin.pagemanagement');
Route::get('admin/addpage', [PageController::class, 'addpage'])->name('admin.addpage');
Route::post('admin/savepage', [PageController::class, 'savepage'])->name('admin.savepage');
Route::get('admin/editpage/{id}', [PageController::class, 'editpage'])->name('admin.editpage');
Route::post('admin/updatepage', [PageController::class, 'updatepage'])->name('admin.updatepage');
Route::post('admin/deletepage/{id}', [PageController::class, 'deletepage'])->name('admin.deletepage');

Route::get('admin/bannermanagement', [PageController::class, 'bannermanagement'])->name('admin.bannermanagement');
Route::get('admin/addbanner', [PageController::class, 'addbanner'])->name('admin.addbanner');
Route::post('admin/savebanner', [PageController::class, 'savebanner'])->name('admin.savebanner');
Route::get('admin/editbanner/{id}', [PageController::class, 'editbanner'])->name('admin.editbanner');
Route::post('admin/updatebanner', [PageController::class, 'updatebanner'])->name('admin.updatebanner');
Route::post('admin/deletebanner/{id}', [PageController::class, 'deletebanner'])->name('admin.deletebanner');

Route::get('admin/managecontest', [TournamentController::class, 'managecontest'])->name('admin.managecontest');
Route::get('admin/addcontest', [TournamentController::class, 'addcontest'])->name('admin.addcontest');
Route::post('admin/savecontest', [TournamentController::class, 'savecontest'])->name('admin.savecontest');
Route::get('admin/editcontest/{id}', [TournamentController::class, 'editcontest'])->name('admin.editcontest');
Route::post('admin/updatecontest', [TournamentController::class, 'updatecontest'])->name('admin.updatecontest');
Route::post('admin/deletecontest/{id}', [TournamentController::class, 'deletecontest'])->name('admin.deletecontest');
Route::get('admin/applieddetails/{id}', [TournamentController::class, 'applieddetails'])->name('admin.applieddetails');

Route::get('admin/managefreecontest', [TournamentController::class, 'managefreecontest'])->name('admin.managefreecontest');
Route::get('admin/addfreecontest', [TournamentController::class, 'addfreecontest'])->name('admin.addfreecontest');
Route::post('admin/savefreecontest', [TournamentController::class, 'savefreecontest'])->name('admin.savefreecontest');
Route::get('admin/editfreecontest/{id}', [TournamentController::class, 'editfreecontest'])->name('admin.editfreecontest');
Route::post('admin/updatefreecontest', [TournamentController::class, 'updatefreecontest'])->name('admin.updatefreecontest');

Route::get('admin/managestudentsgroup', [TournamentController::class, 'managestudentsgroup'])->name('admin.managestudentsgroup');
Route::get('admin/addstudentsgroup', [TournamentController::class, 'addstudentsgroup'])->name('admin.addstudentsgroup');
Route::post('admin/savestudentsgroup', [TournamentController::class, 'savestudentsgroup'])->name('admin.savestudentsgroup');
Route::get('admin/editstudentsgroup/{id}', [TournamentController::class, 'editstudentsgroup'])->name('admin.editstudentsgroup');
Route::post('admin/updatestudentsgroup', [TournamentController::class, 'updatestudentsgroup'])->name('admin.updatestudentsgroup');
Route::post('admin/deletestudentsgroup/{id}', [TournamentController::class, 'deletestudentsgroup'])->name('admin.deletestudentsgroup');

Route::get('admin/managestudentspattern', [TournamentController::class, 'managestudentspattern'])->name('admin.managestudentspattern');
Route::get('admin/addstudentspattern', [TournamentController::class, 'addstudentspattern'])->name('admin.addstudentspattern');
Route::post('admin/savestudentspattern', [TournamentController::class, 'savestudentspattern'])->name('admin.savestudentspattern');
Route::get('admin/editstudentspattern/{id}', [TournamentController::class, 'editstudentspattern'])->name('admin.editstudentspattern');
Route::post('admin/updatestudentspattern', [TournamentController::class, 'updatestudentspattern'])->name('admin.updatestudentspattern');
Route::post('admin/deletestudentspattern/{id}', [TournamentController::class, 'deletestudentspattern'])->name('admin.deletestudentspattern');

Route::get('admin/manageclasssubject', [TournamentController::class, 'manageclasssubject'])->name('admin.manageclasssubject');
Route::get('admin/addclasssubject', [TournamentController::class, 'addclasssubject'])->name('admin.addclasssubject');
Route::post('admin/saveclasssubject', [TournamentController::class, 'saveclasssubject'])->name('admin.saveclasssubject');
Route::get('admin/editclasssubject/{id}', [TournamentController::class, 'editclasssubject'])->name('admin.editclasssubject');
Route::post('admin/updateclasssubject', [TournamentController::class, 'updateclasssubject'])->name('admin.updateclasssubject');
Route::post('admin/deleteclasssubject/{id}', [TournamentController::class, 'deleteclasssubject'])->name('admin.deleteclasssubject');

Route::get('admin/managemathchapter', [TournamentController::class, 'managemathchapter'])->name('admin.managemathchapter');
Route::get('admin/addmathchapter', [TournamentController::class, 'addmathchapter'])->name('admin.addmathchapter');
Route::post('admin/savemathchapter', [TournamentController::class, 'savemathchapter'])->name('admin.savemathchapter');
Route::get('admin/editmathchapter/{id}', [TournamentController::class, 'editmathchapter'])->name('admin.editmathchapter');
Route::post('admin/updatemathchapter', [TournamentController::class, 'updatemathchapter'])->name('admin.updatemathchapter');
Route::post('admin/deletemathchapter/{id}', [TournamentController::class, 'deletemathchapter'])->name('admin.deletemathchapter');

Route::get('admin/managequestions', [TournamentController::class, 'managequestions'])->name('admin.managequestions');
Route::get('admin/addquestions', [TournamentController::class, 'addquestions'])->name('admin.addquestions');
Route::post('admin/savequestions', [TournamentController::class, 'savequestions'])->name('admin.savequestions');
Route::get('admin/editquestions/{id}', [TournamentController::class, 'editquestions'])->name('admin.editquestions');
Route::post('admin/updatequestions', [TournamentController::class, 'updatequestions'])->name('admin.updatequestions');
Route::post('admin/deletequestions/{id}', [TournamentController::class, 'deletequestions'])->name('admin.deletequestions');

Route::get('admin/managequestionssets', [TournamentController::class, 'managequestionssets'])->name('admin.managequestionssets');
Route::get('admin/addquestionsset', [TournamentController::class, 'addquestionsset'])->name('admin.addquestionsset');
Route::post('admin/savequestionsset', [TournamentController::class, 'savequestionsset'])->name('admin.savequestionsset');
Route::get('admin/editquestionsset/{id}', [TournamentController::class, 'editquestionsset'])->name('admin.editquestionsset');
Route::post('admin/updatequestionsset', [TournamentController::class, 'updatequestionsset'])->name('admin.updatequestionsset');
Route::post('admin/deletequestionsset/{id}', [TournamentController::class, 'deletequestionsset'])->name('admin.deletequestionsset');

Route::get('admin/loadquestions', [TournamentController::class, 'loadquestions'])->name('admin.loadquestions');
Route::get('admin/loadquestionscince', [TournamentController::class, 'loadquestionscince'])->name('admin.loadquestionscince');
Route::get('admin/loadquestionhindi', [TournamentController::class, 'loadquestionhindi'])->name('admin.loadquestionhindi');
Route::get('admin/loadquestionenglish', [TournamentController::class, 'loadquestionenglish'])->name('admin.loadquestionenglish');
Route::get('admin/loadquestionmaths', [TournamentController::class, 'loadquestionmaths'])->name('admin.loadquestionmaths');

Route::get('admin/assigncompetition', [TournamentController::class, 'assigncompetition'])->name('admin.assigncompetition');
Route::get('admin/addassigncompetition', [TournamentController::class, 'addassigncompetition'])->name('admin.addassigncompetition');
Route::post('admin/saveassigncompetition', [TournamentController::class, 'saveassigncompetition'])->name('admin.saveassigncompetition');
Route::get('admin/editassigncompetition/{id}', [TournamentController::class, 'editassigncompetition'])->name('admin.editassigncompetition');
Route::post('admin/updateassigncompetition', [TournamentController::class, 'updateassigncompetition'])->name('admin.updateassigncompetition');
Route::post('admin/deleteassigncompetition/{id}', [TournamentController::class, 'deleteassigncompetition'])->name('admin.deleteassigncompetition');

Route::get('admin/freeassigncompetition', [TournamentController::class, 'freeassigncompetition'])->name('admin.freeassigncompetition');
Route::get('admin/addfreeassigncompetition', [TournamentController::class, 'addfreeassigncompetition'])->name('admin.addfreeassigncompetition');
Route::post('admin/savefreeassigncompetition', [TournamentController::class, 'savefreeassigncompetition'])->name('admin.savefreeassigncompetition');
Route::get('admin/editfreeassigncompetition/{id}', [TournamentController::class, 'editfreeassigncompetition'])->name('admin.editfreeassigncompetition');
Route::post('admin/updatefreeassigncompetition', [TournamentController::class, 'updatefreeassigncompetition'])->name('admin.updatefreeassigncompetition');

Route::get('admin/amountrequest', [WalletController::class, 'amountrequest'])->name('admin.amountrequest'); 
Route::get('admin/amountrequestaccepted', [WalletController::class, 'amountrequestaccepted'])->name('admin.amountrequestaccepted'); 
Route::get('admin/rejectrequest', [WalletController::class, 'rejectrequest'])->name('admin.rejectrequest'); 
Route::post('admin/changestatus/{id}', [WalletController::class, 'changestatus'])->name('admin.changestatus');

Route::get('admin/withdrawrequest', [WalletController::class, 'withdrawrequest'])->name('admin.withdrawrequest'); 
Route::get('admin/withdrawrequestaccepted', [WalletController::class, 'withdrawrequestaccepted'])->name('admin.withdrawrequestaccepted'); 
Route::get('admin/rejectwithdraw', [WalletController::class, 'rejectwithdraw'])->name('admin.rejectwithdraw'); 
Route::post('admin/changewithdrawstatus/{id}', [WalletController::class, 'changewithdrawstatus'])->name('admin.changewithdrawstatus');

Route::get('admin/examresult', [WalletController::class, 'examresult'])->name('admin.examresult');

Route::get('admin/scholarshipcompetition', [TournamentController::class, 'scholarshipcompetition'])->name('admin.scholarshipcompetition'); 
Route::get('admin/resultdetails/{id}', [TournamentController::class, 'resultdetails'])->name('admin.resultdetails');
Route::post('admin/paymentdistribute/{id}', [TournamentController::class, 'paymentdistribute'])->name('admin.paymentdistribute');

Route::get('admin/appmanagement', [TournamentController::class, 'appmanagement'])->name('admin.appmanagement');
Route::post('admin/savemanagement', [TournamentController::class, 'savemanagement'])->name('admin.savemanagement');

Route::get('admin/loadallmatch/{id}', [TournamentController::class, 'loadallmatch'])->name('admin.loadallmatch');
});

Route::middleware('admin.role:platform,school')->group(function () {
Route::get('admin/editschoolprofile/{id}', [UsersController::class, 'editschoolprofile'])->name('admin.editschoolprofile');
Route::post('admin/updateschoolprofile', [UsersController::class, 'updateschoolprofile'])->name('admin.updateschoolprofile');
});

Route::middleware('admin.role:platform,institute,school')->group(function () {
Route::get('admin/schoolstudents', [UsersController::class, 'schoolstudents'])->name('admin.schoolstudents');
Route::get('admin/studentscontest/{id}', [UsersController::class, 'studentscontest'])->name('admin.studentscontest');
Route::get('admin/userprofile/{id}', [UsersController::class, 'userprofile'])->name('admin.userprofile');
Route::get('admin/examreaultdetaiils/{id}/{stid}', [UsersController::class, 'examreaultdetaiils'])->name('admin.examreaultdetaiils');
Route::get('admin/studentpaymentdetails', [UsersController::class, 'studentpaymentdetails'])->name('admin.studentpaymentdetails');
Route::get('admin/userpayments/{id}', [UsersController::class, 'userpayments'])->name('admin.userpayments');
Route::get('admin/studentcompetition', [UsersController::class, 'studentcompetition'])->name('admin.studentcompetition');
Route::get('admin/competitionstudentsdetails/{id}', [UsersController::class, 'competitionstudentsdetails'])->name('admin.competitionstudentsdetails');
});

Route::middleware('admin.role:platform,institute,school')->group(function () {
Route::get('admin/changepassword', [UsersController::class, 'changepassword'])->name('admin.changepassword');
Route::post('admin/updatepassword', [UsersController::class, 'updatepassword'])->name('admin.updatepassword');
});

});
