<?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('KepalaSekolah/resetpassword','LoginController@resetpass')->name('kepalasekolah.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::resource('akunsiswa','AkunCtrl');


    Route::post('/Daftar/{id}','DaftarCtrl@show');
    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::resource('ruang','RuangController');
    Route::post('ruang/store', 'RuangController@store');
    Route::post('ruang/update', 'RuangController@update');
    Route::post('ruang/destroy', 'RuangController@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::post('orangtua/storewali','OrangTuaController@storewali');
    Route::resource('prestasi','PrestasiController');
    Route::resource('periodik','PeriodikController');
    Route::resource('asalsekolah','AsalsekolahCtrl');
    Route::resource('downloadpeng','UploadsController@indexpeng');
    Route::resource('downloadsoal','UploadsController@indexsoal');
    Route::resource('pdf','PDFController@index');
    Route::resource('getPDF/kartu','PDFController@getPDF');
    Route::resource('getPDF','PDFController');
    Route::post('/prestasi/create',array('as' => 'create','uses'=>'PrestasiController@insert'));
});


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

    Route::resource('daftarpen','DaftarPendaftarCtrl');
});
