<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SantriController;
use App\Http\Controllers\PaymentTypeController;
use App\Http\Controllers\PaymentController;
use Inertia\Inertia;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return Inertia::render('Welcome', [
        'canLogin' => Route::has('login'),
        'canRegister' => Route::has('register'),
        'laravelVersion' => Application::VERSION,
        'phpVersion' => PHP_VERSION,
    ]);
});

// santri
Route::get('/data-santri', [SantriController::class, 'index'])->name('indexSantri');
Route::post('/addsantris', [SantriController::class, 'store'])->name('storeSantri');
Route::post('/updatesantris/{id}', [SantriController::class, 'update'])->name('updateSantri');
Route::post('/deletesantris/{id}', [SantriController::class, 'destroy'])->name('deleteSantri');

// payment type
Route::get('/data-payment-type', [PaymentTypeController::class, 'index'])->name('indexPaymentType');
Route::post('addpayment_types', [PaymentTypeController::class, 'store'])->name('storePaymentType');
Route::post('/updatepayment_types/{id}', [PaymentTypeController::class, 'update'])->name('updatePaymentType');
Route::post('/deletepayment_types/{id}', [PaymentTypeController::class, 'destroy'])->name('deletePaymentType');

// manual payment
Route::get('/manualPayment', [PaymentController::class, 'index'])->name('indexManualPayment');

Route::get('/dashboard', function () {
    return Inertia::render('Dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

require __DIR__ . '/auth.php';
