<?php

use App\Http\Controllers\AdminController;
use App\Http\Controllers\AuthController;
use Illuminate\Support\Facades\Route;


/*
|--------------------------------------------------------------------------
| 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 redirect('login');
});


Route::get('login', [AuthController::class, 'login']);
Route::get('logout', [AuthController::class, 'logout']);
Route::post('loginproses', [AuthController::class, 'loginproses']);
Route::get('register', [AuthController::class, 'register']);
Route::post('registersimpan', [AuthController::class, 'registersimpan']);
Route::get('forgotpassword', [AuthController::class, 'forgotpassword']);
Route::post('forgotpasswordsend', [AuthController::class, 'forgotpasswordsend']);

Route::get('reset-password/{id}', [AuthController::class, 'resetpasswordform']);
Route::post('reset-password', [AuthController::class, 'resetpassword']);

// route group admin
Route::middleware(['authentication'])->controller(AdminController::class)->group(function () {
    Route::get('admin', 'dashboard'); 

    Route::get('/admin/nasabah', 'nasabahdaftar')->name('nasabah.daftar');
    Route::get('/admin/nasabah/tambah', 'nasabahtambah')->name('nasabah.tambah');
    Route::post('/admin/nasabah/simpan', 'nasabahsimpan')->name('nasabah.simpan');
    Route::get('/admin/nasabah/edit/{id}', 'nasabahedit')->name('nasabah.edit');
    Route::post('/admin/nasabah/update/{id}', 'nasabahupdate')->name('nasabah.update');
    Route::get('/admin/nasabah/hapus/{id}', 'nasabahhapus')->name('nasabah.hapus');

    Route::get('/admin/datanilai', 'datanilai');
    Route::get('/admin/laporan', 'laporan');
    Route::get('/admin/laporancetak', 'laporancetak');
    Route::get('/admin/pengaturan', 'pengaturan');
    Route::post('/admin/pengaturansimpan', 'pengaturansimpan');
});
