<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/
Route::get('/',function(){
	return view('index');
});

Route::get('/home',function(){
    return view('calonsiswa.dashboard');
});

//route untuk authentication
Route::group(['namespace' => 'auth'],function(){
        
    Route::get('/login',function(){
    return view('auth.login');
    })->middleware('guest');

    Route::post('/login','LoginController@login')->name('login');
    
    Route::get('/logout',function(){
        Auth::logout();
        return redirect('/');
    })->name('logout');

    Route::get('/register', 'RegisterController@showRegistrationForm');

    Route::post('/register', 'RegisterController@register')->name('register');

    Route::get('TataUsaha/resetpassword','LoginController@resetpass')->name('tatausaha.resetpass')->middleware('tatausaha');

    Route::get('CalonSiswa/resetpassword','LoginController@resetpass')->name('calonsiswa.resetpass')->middleware('calonsiswa');

    Route::get('HeadMaster/resetpassword','LoginController@resetpass')->name('headmaster.resetpass')->middleware('headmaster');

    Route::post('resetpassword','LoginController@reset')->name('reset');
});



//route untuk tatausaha
Route::group(['namespace' => 'tatausaha','prefix' => 'tatausaha','middleware' => 'tatausaha'], 
    function() {
    Route::get('/', function () {
        return view('TataUsaha.dashboard',['title' => 'Dashboard']);
    })->name('tatausaha');

    Route::resource('Daftar','DaftarCtrl');
    Route::post('/editItem','DaftarCtrl@editItem');

    Route::resource('upload','UploadsController');
    Route::post('upload/create', 'UploadsController@multiple_upload');
    Route::resource('tahunajaran','T_ajarController@index');

    Route::post('tahunajaran/store', 'T_ajarController@store');
    Route::post('tahunajaran/update', 'T_ajarController@update');
    Route::post('tahunajaran/destroy', 'T_ajarController@destroy');

});






//route untuk calonsiswa
Route::group(['namespace' => 'calonsiswa','prefix' => 'calonsiswa','middleware' => 'calonsiswa'], function() {
    Route::get('/', function () {
        return view('CalonSiswa.dashboard',['title' => 'Dashboard']);
    })->name('calonsiswa');  

    Route::resource('pendaftar','PendaftarController');
    Route::resource('Data','PendaftarController');
    Route::resource('hasilujian','PendaftarController@hasilujian');
    Route::resource('orangtua','OrangTuaController');
    Route::resource('prestasi','PrestasiController');
    Route::resource('periodik','PeriodikController');
    Route::resource('asalsekolah','AsalsekolahCtrl');

    Route::resource('downloadpeng','UploadsController@indexpeng');

    Route::resource('downloadsoal','UploadsController@indexsoal');

});


//route untuk Headmaster
Route::group(['namespace' => 'headmaster','prefix' => 'headmaster','middleware' => 'headmaster'], function() {
    Route::get('/', function () {
        return view('HeadMaster.dashboard',['title' => 'Dashboard']);
    })->name('headmaster');  
    
});
