<?php

Route::redirect('/', '/finance/public/login');
Route::get('/home', function () {
    if (session('status')) {
        return redirect()->route('admin.home')->with('status', session('status'));
    }

    return redirect()->route('admin.home');
});

Auth::routes(['register' => false]);
// Admin
Route::get('/paydues/{regno}', 'FormController@paydues')->name('paydues');
Route::get('/form', 'FormController@index')->name('form');
Route::post('/store-form-data', 'FormController@saveform')->name('store-form-data');
Route::post('/load-payment', 'FormController@loadpayment')->name('loadpayment');
Route::get('/save-payment', 'FormController@saveEsewa')->name('save-payment');
Route::post('/save-pay-later', 'FormController@savePayLater')->name('save-pay-later');
Route::get('/connectips', 'FormController@saveConnectIPS')->name('connectips');
 

Route::post('/generate_otp', 'FormController@generate_otp')->name('generate_otp');
Route::post('/check_otp', 'FormController@check_otp')->name('check_otp');


Route::group(['prefix' => 'admin', 'as' => 'admin.', 'namespace' => 'Admin', 'middleware' => ['auth']], function () {
    Route::get('/', 'HomeController@index')->name('home');
    // Permissions
    Route::delete('permissions/destroy', 'PermissionsController@massDestroy')->name('permissions.massDestroy');
    Route::resource('permissions', 'PermissionsController');

    // Roles
    Route::delete('roles/destroy', 'RolesController@massDestroy')->name('roles.massDestroy');
    Route::resource('roles', 'RolesController');

    // Users
    Route::delete('users/destroy', 'UsersController@massDestroy')->name('users.massDestroy');
    Route::resource('users', 'UsersController');

    // Subjects
    Route::delete('subjects/destroy', 'SubjectController@massDestroy')->name('subjects.massDestroy');
    Route::post('subjects/subbylevel', 'SubjectController@subbylevel')->name('subjects.subbylevel');
    Route::resource('subjects', 'SubjectController');

    // finances
    Route::delete('finances/destroy', 'FinanceController@massDestroy')->name('finances.massDestroy');
    Route::resource('finances', 'FinanceController');

    // customers
    Route::delete('customers/destroy', 'CustomerController@massDestroy')->name('customers.massDestroy');
    Route::resource('customers', 'CustomerController');

    //get_registered_organization
    Route::get('/get_registered_organization', 'FinanceController@index')->name('get_registered_organization');
    Route::post('/get_registered_organization', 'FinanceController@orgSearch')->name('get_registered_organization');

    //get_registered_customer
Route::get('/get_registered_customer', 'CustomerController@index')->name('get_registered_customer');
Route::post('/get_registered_customer', 'CustomerController@customerSearch')->name('get_registered_customer');

    //get_registered_collector
    Route::get('/get_registered_collector', 'CollectorController@index')->name('get_registered_collector');
    Route::post('/get_registered_collector', 'CollectorController@collectorSearch')->name('get_registered_collector');
    
    //get_transactions
    Route::get('/get_transaction', 'TransactionController@index')->name('get_transaction');
    Route::post('/get_transaction', 'TransactionController@Search')->name('get_transaction');


});
Route::group(['prefix' => 'profile', 'as' => 'profile.', 'namespace' => 'Auth', 'middleware' => ['auth']], function () {
// Change password
    if (file_exists(app_path('Http/Controllers/Auth/ChangePasswordController.php'))) {
        Route::get('password', 'ChangePasswordController@edit')->name('password.edit');
        Route::post('password', 'ChangePasswordController@update')->name('password.update');
    }

});