<?php

use App\Http\Controllers\LoanTopUpController;
use Illuminate\Support\Facades\Route;

Route::middleware('auth')->group(function (): void {
    Route::get('/loan-top-ups',[LoanTopUpController::class,'index'])->middleware('permission:loans.top-up.view')->name('loan-top-ups.index');
    Route::get('/loans/{loan}/top-up',[LoanTopUpController::class,'create'])->middleware(['permission:loans.top-up.create','can:createTopUp,loan'])->name('loan-top-ups.create');
    Route::post('/loans/{loan}/top-up/preview',[LoanTopUpController::class,'preview'])->middleware(['permission:loans.top-up.create','can:createTopUp,loan'])->name('loan-top-ups.preview');
    Route::post('/loans/{loan}/top-up',[LoanTopUpController::class,'store'])->middleware(['permission:loans.top-up.create','can:createTopUp,loan'])->name('loan-top-ups.store');
    Route::get('/loans/{loan}/top-up/execute',[LoanTopUpController::class,'executeForm'])->middleware(['permission:loans.top-up.execute','can:executeTopUp,loan'])->name('loan-top-ups.execute-form');
    Route::post('/loans/{loan}/top-up/execute',[LoanTopUpController::class,'execute'])->middleware(['permission:loans.top-up.execute','can:executeTopUp,loan'])->name('loan-top-ups.execute');
    Route::get('/loan-top-ups/{topUp}',[LoanTopUpController::class,'show'])->middleware(['permission:loans.top-up.view','can:view,topUp'])->name('loan-top-ups.show');
});
