<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\LoginController;

use Illuminate\Support\Facades\Storage;
use Aws\S3\S3Client;
use App\Models\Mail as Mailing;
use Aws\Exception\AwsException;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;

Route::middleware(['guest'])->group(function () {
    Route::post('proses_login', 'App\Http\Controllers\LoginController@proses_login')->name('proses_login')->middleware('check.status');
    Route::get('register', 'App\Http\Controllers\LoginController@register')->name('register');
    Route::post('storeRegister', 'App\Http\Controllers\LoginController@storeRegister')->name('storeRegister');
    Route::get('forgot', 'App\Http\Controllers\LoginController@forgot')->name('forgot');
    Route::post('forgotPassword', 'App\Http\Controllers\LoginController@forgotPassword')->name('forgotPassword');
    Route::get('reset/{token}', 'App\Http\Controllers\LoginController@reset')->name('reset');
    Route::post('resetPassword', 'App\Http\Controllers\LoginController@resetPassword')->name('resetPassword');
    Route::get('verify/{token}', 'App\Http\Controllers\LoginController@verify')->name('verify');
});
// page utama
Route::get('/', 'App\Http\Controllers\LoginController@index')->name('login')->middleware('check.auth');
Route::get('logout', 'App\Http\Controllers\LoginController@logout')->name('logout');
Route::group(['middleware' => ['auth','check.admin']], function () {
    Route::get('change-language/{locale}', function ($locale) {
        App::setLocale($locale);
        Config::set('app.locale', $locale);
        return back()->with('swal', swal_alert('success', 'Language Changed'));
    });
    Route::group(['prefix' => 'app'], function () {
        Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard');
        Route::prefix('account')->group(function () {
            Route::get('/', 'App\Http\Controllers\DashboardController@profile')->name('account');
            Route::post('update', 'App\Http\Controllers\DashboardController@update')->name('update.account');
            Route::get('activity', 'App\Http\Controllers\AdminController@activity')->name('account.activity');
        });

        Route::prefix('gejala')->group(function () {
            // Gejala
            Route::get('/', 'App\Http\Controllers\GejalaController@index')->name('gejala');
            Route::get('create', 'App\Http\Controllers\GejalaController@create')->name('gejala.create');
            Route::post('store', 'App\Http\Controllers\GejalaController@store')->name('gejala.store');
            Route::get('edit/{id}', 'App\Http\Controllers\GejalaController@edit')->name('gejala.edit');
            Route::post('update/{id}', 'App\Http\Controllers\GejalaController@update')->name('gejala.update');
            Route::get('delete/{id}', 'App\Http\Controllers\GejalaController@destroy')->name('gejala.delete');
        });

        Route::prefix('penyakit')->group(function () {
            // Gejala
            Route::get('/', 'App\Http\Controllers\PenyakitController@index')->name('penyakit');
            Route::get('create', 'App\Http\Controllers\PenyakitController@create')->name('penyakit.create');
            Route::post('store', 'App\Http\Controllers\PenyakitController@store')->name('penyakit.store');
            Route::get('edit/{id}', 'App\Http\Controllers\PenyakitController@edit')->name('penyakit.edit');
            Route::post('update/{id}', 'App\Http\Controllers\PenyakitController@update')->name('penyakit.update');
            Route::get('delete/{id}', 'App\Http\Controllers\PenyakitController@destroy')->name('penyakit.delete');
        });

        Route::prefix('rule')->group(function () {
            // Gejala
            Route::get('/', 'App\Http\Controllers\RuleController@index')->name('rule');
            Route::get('create', 'App\Http\Controllers\RuleController@create')->name('rule.create');
            Route::post('store', 'App\Http\Controllers\RuleController@store')->name('rule.store');
            Route::get('edit/{id}', 'App\Http\Controllers\RuleController@edit')->name('rule.edit');
            Route::post('update/{id}', 'App\Http\Controllers\RuleController@update')->name('rule.update');
            Route::get('delete/{id}', 'App\Http\Controllers\RuleController@destroy')->name('rule.delete');
        });

        Route::prefix('users')->group(function () {
            Route::get('/', 'App\Http\Controllers\UsersController@index')->name('users');
            Route::get('create', 'App\Http\Controllers\UsersController@create')->name('users.create');
            Route::post('store', 'App\Http\Controllers\UsersController@store')->name('users.store');
            Route::get('edit/{id}', 'App\Http\Controllers\UsersController@edit')->name('users.edit');
            Route::post('update/{id}', 'App\Http\Controllers\UsersController@update')->name('users.update');
            Route::get('delete/{id}', 'App\Http\Controllers\UsersController@destroy')->name('users.delete');
            Route::get('detail/{id}', 'App\Http\Controllers\UsersController@show')->name('users.show');
        });

        Route::get('riwayat', 'App\Http\Controllers\RiwayatController@index')->name('riwayat');
        Route::get('riwayat/delete/{id}', 'App\Http\Controllers\RiwayatController@delete')->name('riwayat.delete');
    });
});
