<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\CityController;
use App\Http\Controllers\Admin\ParkController;
use App\Http\Controllers\Admin\PriceListController;
use App\Http\Controllers\Admin\PriceController;
use App\Http\Controllers\Admin\PsectionController;
use App\Http\Controllers\Admin\PtypeController;
use App\Http\Controllers\Admin\PeriodicalController;
use App\Http\Controllers\Admin\NewsController;
use App\Http\Controllers\Admin\UsersController;
use App\Http\Controllers\Admin\RegularContractController;
use App\Http\Controllers\Admin\ReservesController;
use App\Http\Controllers\Admin\UsertypeController;
use App\Http\Controllers\Admin\ContractorController;
use App\Http\Controllers\Admin\ContractorListController;
use App\Http\Controllers\Admin\UpdateCandidateController;
use App\Http\Controllers\Admin\ReservationController;
use App\Http\Controllers\Admin\PersonalController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\Auth\ResetPasswordController;
use App\Http\Controllers\Admin\OpesController;
use App\Http\Controllers\Admin\InformationController;
use App\Http\Controllers\Admin\TagissueController;
use App\Http\Controllers\Admin\SealsController;
use App\Http\Controllers\Admin\RegularTypeController;
use App\Http\Controllers\Admin\StationController;
use App\Http\Controllers\Admin\TermsController;
use App\Http\Controllers\Admin\JurisdictionParkingController;
use App\Http\Controllers\Admin\PrintAreaController;
use App\Http\Controllers\Admin\ContractAllowableCityController;
use App\Http\Controllers\Admin\ManagerController;
use App\Http\Controllers\Admin\TaxController;
use App\Http\Controllers\Admin\PaymentController;
use App\Http\Controllers\Admin\SettlementTransactionController;
use App\Http\Controllers\Admin\OpeController;
use App\Http\Controllers\Admin\DeviceController;
use App\Http\Controllers\Admin\OperatorQueController;
use App\Http\Controllers\Admin\SettingController;
use App\Http\Controllers\Admin\MailTemplateController;
use App\Http\Controllers\Admin\InvSettingController;
use App\Http\Controllers\Admin\ZoneController;
use App\Http\Controllers\Admin\PplaceController;
use App\Http\Controllers\Admin\ReductionConfirmMasterController;
use App\Http\Controllers\Admin\ParkingRegulationsController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\Auth\EmailOtpController;


/**
 * Laravel 12変更点：ルート定義の書き方が変更
 * Laravel 5.7: Route::get('url', 'Controller@method') の形式
 * Laravel 12: Route::get('url', [Controller::class, 'method']) の形式
 */

// ホームページのリダイレクト
Route::get('/', function () {
    return redirect()->route('home');
});

// ログイン関連ルート（ゲストユーザー専用）
// Laravel 12変更点：ミドルウェアをルートで直接指定
Route::middleware('guest')->group(function () {
    // ログインフォーム表示
    Route::get('login', [App\Http\Controllers\Auth\LoginController::class, 'showLoginForm'])->name('login');
    // ログイン処理
    Route::post('login', [App\Http\Controllers\Auth\LoginController::class, 'login']);
    Route::get('/forgot-password', [ForgotPasswordController::class, 'showLinkRequestForm'])->name('forgot_password');
    Route::post('/forgot-password', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('forgot_password.send');
    // パスワードリセット
    Route::get('/reset-password', [ResetPasswordController::class, 'showResetForm'])->name('password.reset');
    Route::post('/reset-password', [ResetPasswordController::class, 'reset'])->name('password.update');

});

// ログアウトルート（認証済みユーザー専用、OTP チェック対象外）
Route::get('logout', [App\Http\Controllers\Auth\LoginController::class, 'logout'])
    ->middleware(['auth'])
    ->name('logout');



// 保護されたルート（認証済みユーザー専用）
// Laravel 12変更点：middleware()をコントローラーではなくルートで指定
Route::middleware('auth')->group(function () {
    // OTP メール認証ルート（OTP チェック対象外、ここに配置）
    // ログイン直後に OTP（ワンタイムパスワード）コード入力画面を表示・検証
    Route::prefix('otp')->name('otp.')->group(function () {
        Route::get('/', [EmailOtpController::class, 'show'])->name('show');
        Route::post('/', [EmailOtpController::class, 'verify'])->name('verify');
        Route::post('/resend', [EmailOtpController::class, 'resend'])->name('resend');
    });

    // パスワード変更ルート（OTP チェック対象外、有効期限チェック対象）
    // 定期的なパスワード変更が必須（3ヶ月ごと）
    Route::prefix('password')->name('password.')->group(function () {
        Route::get('/change', [App\Http\Controllers\Auth\PasswordChangeController::class, 'showChangeForm'])->name('change.show');
        Route::post('/change', [App\Http\Controllers\Auth\PasswordChangeController::class, 'updatePassword'])->name('change.update');
        Route::get('/success', [App\Http\Controllers\Auth\PasswordChangeController::class, 'showSuccessPage'])->name('change.success');
    })->middleware('check.password.change.required');

    // 以下のすべてのルートに OTP 認証チェックミドルウェアを適用
    Route::middleware('ensure.otp.verified')->group(function () {
        // ダッシュボード（ホーム画面）
        // パスワード有効期限チェック対象：3ヶ月超過時は強制リダイレクト
        Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])
            ->name('home')
            ->middleware('check.password.change.required');

        // Laravel 12 移行時の一時的な占位符路由
        // 他の開発者が継続して開発できるように、エラーを防ぐための仮ルート定義
        // 実装完了後は各機能の正式なルートに置き換える予定

        // 利用者マスタ管理機能（仮ルート）
        Route::match(['get', 'post'], '/users', function () {
            return view('admin.placeholder', ['title' => '利用者マスタ', 'feature' => 'users']);
        })->name('users');

        Route::match(['get', 'post'], '/users/add', function () {
            return view('admin.placeholder', ['title' => '利用者追加', 'feature' => 'users']);
        })->name('user_add');

        Route::match(['get', 'post'], '/users/edit/{seq}', function ($seq) {
            return view('admin.placeholder', ['title' => '利用者編集', 'feature' => 'users', 'id' => $seq]);
        })->name('user_edit')->where(['seq' => '[0-9]+']);

        Route::match(['get', 'post'], '/users/info/{seq}', function ($seq) {
            return view('admin.placeholder', ['title' => '利用者詳細', 'feature' => 'users', 'id' => $seq]);
        })->name('user_info')->where(['seq' => '[0-9]+']);

        Route::match(['get', 'post'], '/users/import', function () {
            return redirect()->route('users')->with('info', 'インポート機能は現在実装中です。');
        })->name('users_import');

        Route::get('/users/export', function () {
            return redirect()->route('users')->with('info', 'エクスポート機能は現在実装中です。');
        })->name('users_export');

        // その他の管理機能の仮ルート（必要に応じて追加）
        Route::match(['get', 'post'], '/regular_contracts', function () {
            return view('admin.placeholder', ['title' => '定期契約管理', 'feature' => 'regular_contracts']);
        })->name('regular_contracts');

    Route::match(['get', 'post'], '/parks', function () {
        return view('admin.placeholder', ['title' => '駐輪場管理', 'feature' => 'parks']);
    })->name('parks');

    

    // 区画別利用率状況 
    Route::get('/using_status', [App\Http\Controllers\Admin\UsingStatusController::class, 'index'])->name('using_status');
    Route::post('/using_status', [App\Http\Controllers\Admin\UsingStatusController::class, 'index'])->name('using_status');
    
    // 将来拡張用API・エクスポート機能
    Route::get('/using_status/api', [App\Http\Controllers\Admin\UsingStatusController::class, 'apiGetUtilization'])->name('using_status.api');
    Route::get('/using_status/export', [App\Http\Controllers\Admin\UsingStatusController::class, 'exportCsv'])->name('using_status.export');


    // sou start
    // [東京都|〇〇駐輪場] 定期契約マスタ
    Route::match(['get', 'post'], '/regular_contracts', [App\Http\Controllers\Admin\RegularContractController::class, 'list'])->name('regular_contracts');
    Route::match(['get', 'post'], '/regular_contracts/add', [App\Http\Controllers\Admin\RegularContractController::class, 'add'])->name('regular_contract_add');
    Route::match(['get', 'post'], '/regular_contracts/edit/{contract_id}', [App\Http\Controllers\Admin\RegularContractController::class, 'edit'])->name('regular_contract_edit')->where(['contract_id' => '[0-9]+']);
    Route::match(['get', 'post'], '/regular_contracts/info/{contract_id}', [App\Http\Controllers\Admin\RegularContractController::class, 'info'])->name('regular_contract_info')->where(['contract_id' => '[0-9]+']);
    Route::match(['get', 'post'], '/regular_contracts/delete', [App\Http\Controllers\Admin\RegularContractController::class, 'delete'])->name('regular_contracts_delete');
    Route::match(['get', 'post'], '/regular_contracts/import', [App\Http\Controllers\Admin\RegularContractController::class, 'import'])->name('regular_contracts_import');
    Route::get('/regular_contracts/export', [App\Http\Controllers\Admin\RegularContractController::class, 'export'])->name('regular_contracts_export');

    // [東京都|〇〇駐輪場] 駐輪車室マスタ
    Route::match(['get', 'post'], '/pplace', [PplaceController::class, 'list'])->name('pplaces');
    Route::match(['get', 'post'], '/pplace/add', [PplaceController::class, 'add'])->name('pplaces_add');
    Route::match(['get', 'post'], '/pplace/edit/{id}', [PplaceController::class, 'edit'])->name('pplaces_edit')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/pplace/info/{id}', [PplaceController::class, 'info'])->name('pplaces_info')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/pplace/delete', [PplaceController::class, 'delete'])->name('pplaces_delete');
    Route::match(['get', 'post'], '/pplace/import', [PplaceController::class, 'import'])->name('pplaces_import');
    Route::get('/pplace/export', [PplaceController::class, 'export'])->name('pplaces_export');
    // sou end

    // ou start
    // 自治体ダッシュボード
    Route::get('/city/{city_id}/dashboard', [CityController::class, 'dashboard'])
        ->where(['city_id' => '[0-9]+'])
        ->name('city_dashboard')
        ->middleware('check.city.access');
    
    // 市区マスタ
    Route::get('/city', [CityController::class, 'list'])->name('city');
    Route::get('/city/add', [CityController::class, 'add'])->name('city.add');
    Route::post('/city/add', [CityController::class, 'store'])->name('city.store');
    Route::get('/city/edit/{id}', [CityController::class, 'edit'])
        ->whereNumber('id')
        ->name('city.edit');
    Route::put('/city/edit/{id}', [CityController::class, 'update'])
        ->whereNumber('id')
        ->name('city.update');
    Route::post('/city/delete', [CityController::class, 'delete'])->name('city.delete');


    //2026.02.05 kin
    // 駐輪場マスタ
    Route::get('/parks', [ParkController::class, 'list'])->name('parks');

    Route::get('/parks/add', [ParkController::class, 'add'])->name('parks.add');
    Route::post('/parks/add', [ParkController::class, 'store'])->name('parks.store');

    Route::get('/parks/edit/{id}', [ParkController::class, 'edit'])->name('parks.edit');
    Route::put('/parks/edit/{id}', [ParkController::class, 'update'])->name('parks.update');

    Route::post('/parks/delete', [ParkController::class, 'delete'])->name('parks.delete');

    Route::get('/parks/export', [ParkController::class, 'export'])->name('parks.export');

    Route::post('/parks/check-duplicate', [ParkController::class, 'checkDuplicate'])
        ->name('parks.check_duplicate');

    //2026.02.05 kin end



    // 料金一覧表マスタ
    Route::match(['get', 'post'], '/admin/pricelist', [PriceListController::class, 'list'])->name('pricelist');
    Route::post('/admin/pricelist/update', [PriceListController::class, 'update'])->name('pricelist_update');
    Route::post('/admin/pricelist/insert', [PriceListController::class, 'insert'])->name('pricelist_insert');

    //駐輪場所、料金マスタ
    Route::match(['get', 'post'], '/admin/prices', [PriceController::class, 'list'])->name('prices');
    Route::match(['get', 'post'], '/admin/prices/add', [PriceController::class, 'add'])->name('price_add');
    Route::match(['get', 'post'], '/admin/prices/edit/{id}', [PriceController::class, 'edit'])->name('price_edit')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/admin/prices/info/{id}', [PriceController::class, 'info'])->name('price_info')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/admin/prices/delete', [PriceController::class, 'delete'])->name('prices_delete');
    Route::match(['get', 'post'], '/admin/prices/import', [PriceController::class, 'import'])->name('prices_import');
    Route::get('/admin/prices/export', [PriceController::class, 'export'])->name('prices_export');
    // POST: 条件付きエクスポート（モーダルで選択）
    Route::post('/admin/prices/export', [PriceController::class, 'exportFiltered'])->name('prices_export_filtered');    


    //車種区分マスタ
    Route::match(['get', 'post'], '/admin/psection', [PsectionController::class, 'list'])->name('psections');
    Route::match(['get', 'post'], '/admin/psection/add', [PsectionController::class, 'add'])->name('psections_add');
    Route::match(['get', 'post'], '/admin/psection/edit/{id}', [PsectionController::class, 'edit'])->name('psections_edit')->where(['id' => '[0-9]+']);
    Route::post('/admin/psection/delete', [PsectionController::class, 'delete'])->name('psections_delete');

    //駐輪分類マスタ
    Route::match(['get', 'post'], '/admin/ptypes', [PtypeController::class, 'list'])->name(name: 'ptypes');
    Route::match(['get', 'post'], '/admin/ptypes/add', [PtypeController::class, 'add'])->name('ptypes_add');
    Route::match(['get', 'post'], '/admin/ptypes/edit/{id}', [PtypeController::class, 'edit'])->name('ptypes_edit')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/admin/ptypes/info/{id}', [PtypeController::class, 'info'])->name('ptypes_info')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/admin/ptypes/delete', [PtypeController::class, 'delete'])->name('ptypes_delete');
    Route::match(['get', 'post'], '/admin/ptypes/import', [PtypeController::class, 'import'])->name('ptypes_import');
    Route::get('/admin/ptypes/export', [PtypeController::class, 'export'])->name('ptypes_export');

    //定期利用・契約状況
    Route::match(['get', 'post'], '/periodical', [PeriodicalController::class, 'list'])->name('periodical');
    Route::get('/periodical/list-data', [PeriodicalController::class, 'listData'])->name('periodical.listData');
    Route::get('/periodical/area', [PeriodicalController::class, 'area'])->name('periodical.area');
    Route::get('/periodical/area-list-data', [PeriodicalController::class, 'areaListData'])->name('periodical.areaListData');

    // 一般ウェブ管理 ＞ 最新ニュース登録
    Route::match(['get', 'post'], '/web/news', [NewsController::class, 'list'])->name('news');
    Route::match(['get', 'post'], '/web/news/add', [NewsController::class, 'add'])->name('news_add');
    Route::match(['get', 'post'], '/web/news/edit/{id}', [NewsController::class, 'edit'])->where(['id' => '[0-9]+'])->name('news_edit');
    Route::match(['get', 'post'], '/web/news/info/{id}', [NewsController::class, 'info'])->where(['id' => '[0-9]+'])->name('news_info');
    Route::match(['get', 'post'], '/web/news/delete', [NewsController::class, 'delete'])->name('news_delete');

    // 利用者マスタ
    Route::match(['get', 'post'], '/users', [UsersController::class, 'list'])->name('users');
    Route::match(['get', 'post'], '/users/add', [UsersController::class, 'add'])->name('users_add');
    Route::match(['get', 'post'], '/users/edit/{seq}', [UsersController::class, 'edit'])->where(['seq' => '[0-9]+'])->name('users_edit');
    Route::match(['get', 'post'], '/users/export', [UsersController::class, 'export'])->name('users_export');
    Route::post('/users/delete', [UsersController::class, 'delete'])->name('users_delete');

    // 定期契約マスタ
    Route::match(['get', 'post'], '/regularcontracts', [RegularContractController::class, 'list'])->name('regularcontracts');
    Route::match(['get', 'post'], '/regularcontracts/add', [RegularContractController::class, 'add'])->name('regularcontracts_add');
    Route::match(['get', 'post'], '/regularcontracts/edit/{contract_id}', [RegularContractController::class, 'edit'])->where(['contract_id' => '[0-9]+'])->name('regularcontracts_edit');
    Route::match(['get', 'post'], '/regularcontracts/import', [RegularContractController::class, 'import'])->name('regularcontracts_import');
    Route::get('/regularcontracts/export', [RegularContractController::class, 'export'])->name('regularcontracts_export')->middleware('auth');
    Route::match(['get', 'post'], '/regularcontracts/info/{contract_id}', [RegularContractController::class, 'info'])->where(['contract_id' => '[0-9]+'])->name('regularcontracts_info');
    Route::match(['get', 'post'], '/regularcontracts/delete', [RegularContractController::class, 'delete'])->name('regularcontracts_delete');

    // 定期予約マスタ
    Route::match(['get', 'post'], '/reserves', [ReservesController::class, 'list'])->name('reserves');
    Route::match(['get', 'post'], '/reserves/add', [ReservesController::class, 'add'])->name('reserves_add');
    Route::match(['get', 'post'], '/reserves/edit/{reserve_id}', [ReservesController::class, 'edit'])->name('reserves_edit');
    Route::match(['get', 'post'], '/reserves/delete', [ReservesController::class, 'delete'])->name('reserves_delete');
    Route::match(['get', 'post'], '/reserves/export', [ReservesController::class, 'export'])->name('reserves_export');

    // 利用者分類マスタ
    Route::match(['get', 'post'], '/usertypes', [UsertypeController::class, 'list'])->name('usertypes');
    Route::match(['get', 'post'], '/usertypes/add', [UsertypeController::class, 'add'])->name('usertype_add');
    Route::match(['get', 'post'], '/usertypes/edit/{id}', [UsertypeController::class, 'edit'])->name('usertype_edit')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/usertypes/info/{id}', [UsertypeController::class, 'info'])->name('usertype_info')->where(['id' => '[0-9]+']);
    Route::match(['get', 'post'], '/usertypes/delete', [UsertypeController::class, 'delete'])->name('usertypes_delete');
    Route::match(['get', 'post'], '/usertypes/import', [UsertypeController::class, 'import'])->name('usertypes_import');
    Route::match(['get', 'post'], '/usertypes/export', [UsertypeController::class, 'export'])->name('usertypes_export');

    // 減免確認マスタ
    Route::get('/reduction-confirm-master', [ReductionConfirmMasterController::class, 'list'])->name('reduction_confirm_list');
    Route::post('/reduction-confirm-master', [ReductionConfirmMasterController::class, 'store'])->name('reduction_confirm_store');

    // 駐輪規定マスタ
    Route::match(['get', 'post'], '/admin/parking-regulations', [ParkingRegulationsController::class, 'list'])->name('parking_regulations_list');
    Route::match(['get', 'post'], '/admin/parking-regulations/add', [ParkingRegulationsController::class, 'add'])->name('parking_regulations_add');
    Route::match(['get', 'post'], '/admin/parking-regulations/edit/{seq}', [ParkingRegulationsController::class, 'edit'])->name('parking_regulations_edit')->where(['seq' => '[0-9]+']);
    Route::post('/admin/parking-regulations/update/{seq}', [ParkingRegulationsController::class, 'update'])->name('parking_regulations_update');
    Route::post('/admin/parking-regulations/delete', [ParkingRegulationsController::class, 'delete'])->name('parking_regulations_delete');

    

    // 契約者一覧
    Route::match(['get', 'post'], '/contractor', [ContractorController::class, 'list'])->name('contractor');

    // 未更新者一覧
    Route::match(['get', 'post'], '/contractor_list', [ContractorListController::class, 'list'])->name('contractor_List');

    // 更新予定者一覧
    Route::match(['get', 'post'], '/update_candidate', [UpdateCandidateController::class, 'list'])->name('update_candidate');

    // 予約者一覧
    Route::match(['get', 'post'], '/reservation', [ReservationController::class, 'list'])->name('reservation');

    // 本人確認手動処理
    Route::match(['get', 'post'], '/personal', [PersonalController::class, 'list'])->name('personal');
    Route::match(['get', 'post'], '/personal/edit/{seq}', [PersonalController::class, 'edit'])->name('personal_edit')->where(['seq' => '[0-9]+']);

    // 常時表示インフォメーション
    Route::get('/information', [InformationController::class, 'list'])->name('information');
    Route::get('/dashboard', [InformationController::class, 'dashboard'])->name('dashboard');
    Route::post('/information/status', [InformationController::class, 'updateStatus'])->name('information.status');

    // タグ発行キュー処理、履歴表示
    Route::get('/tagissue', [App\Http\Controllers\Admin\TagissueController::class, 'list'])->name('tagissue');
    Route::post('/tagissue/status', [App\Http\Controllers\Admin\TagissueController::class, 'updateStatus'])->name('tagissue.status');
    Route::post('/tagissue/check-status', [App\Http\Controllers\Admin\TagissueController::class, 'checkStatus']);
    // タグ発行キュー：宛名PDF印刷
    Route::post('/tagissue/print-unissued-labels', [App\Http\Controllers\Admin\TagissueController::class, 'printUnissuedLabels'])->name('tagissue.print_labels');

    // シール発行履歴
    Route::get('/seals', [SealsController::class, 'list'])->name('seals');

    // ou end

    //kin start
    // [東京都|〇〇駐輪場] 定期種別マスタ
    Route::match(['get', 'post'], '/regular_types', [RegularTypeController::class, 'list'])->name('regular_types');
    Route::match(['get', 'post'], '/regular_types/add', [RegularTypeController::class, 'add'])->name('regular_types_add');
    Route::match(['get', 'post'], '/regular_types/edit/{id}', [RegularTypeController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('regular_types_edit');
    Route::match(['get', 'post'], '/regular_types/info/{id}', [RegularTypeController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('regular_types_info');
    Route::match(['get', 'post'], '/regular_types/delete', [RegularTypeController::class, 'delete'])->name('regular_types_delete');
    Route::match(['get', 'post'], '/regular_types/import', [RegularTypeController::class, 'import'])->name('regular_types_import');
    Route::get('/regular_types/export', [RegularTypeController::class, 'export'])->name('regular_types_export');

    // [東京都|〇〇駐輪場] 近傍駅マスタ
    Route::match(['get', 'post'], '/stations', [StationController::class, 'list'])->name('stations');
    Route::match(['get', 'post'], '/stations/add', [StationController::class, 'add'])->name('stations_add');
    Route::match(['get', 'post'], '/stations/edit/{id}', [StationController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('stations_edit');
    Route::get('/stations/info/{id}', [StationController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('stations_info');
    Route::match(['get', 'post'], '/stations/delete', [StationController::class, 'delete'])->name('stations_delete');
    Route::post('/stations/import', [StationController::class, 'import'])->name('stations_import');
    Route::get('/stations/export', [StationController::class, 'export'])->name('stations_export');

    // [東京都|〇〇駐輪場] 利用契約マスタ
    Route::match(['get', 'post'], '/terms', [TermsController::class, 'list'])->name('terms');
    Route::match(['get', 'post'], '/terms/add', [TermsController::class, 'add'])->name('terms_add');
    Route::match(['get', 'post'], '/terms/edit/{id}', [TermsController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('terms_edit');
    Route::get('/terms/info/{id}', [TermsController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('terms_info');
    // Route::match(['get', 'post'], '/terms/delete', [TermsController::class, 'delete'])->name('terms_delete');
    Route::post('/terms/delete', [TermsController::class, 'delete'])->name('terms_delete');
    Route::post('/terms/import', [TermsController::class, 'import'])->name('terms_import');
    Route::get('/terms/export', [TermsController::class, 'export'])->name('terms_export');

    // [東京都|〇〇駐輪場] 管轄駐輪場マスタ
    Route::match(['get', 'post'], '/jurisdiction_parkings', [JurisdictionParkingController::class, 'list'])->name('jurisdiction_parkings');
    Route::match(['get', 'post'], '/jurisdiction_parkings/add', [JurisdictionParkingController::class, 'add'])->name('jurisdiction_parkings_add');
    Route::match(['get', 'post'], '/jurisdiction_parkings/edit/{id}', [JurisdictionParkingController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('jurisdiction_parkings_edit');
    Route::get('/jurisdiction_parkings/info/{id}', [JurisdictionParkingController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('jurisdiction_parkings_info');
    Route::match(['get', 'post'], '/jurisdiction_parkings/delete', [JurisdictionParkingController::class, 'delete'])->name('jurisdiction_parkings_delete');
    Route::post('/jurisdiction_parkings/import', [JurisdictionParkingController::class, 'import'])->name('jurisdiction_parkings_import');
    Route::get('/jurisdiction_parkings/export', [JurisdictionParkingController::class, 'export'])->name('jurisdiction_parkings_export');

    // [東京都|〇〇駐輪場] シール印刷範囲マスタ
   Route::match(['get', 'post'], '/print_areas', [PrintAreaController::class, 'list'])->name('print_areas');
    Route::match(['get', 'post'], '/print_areas/add', [PrintAreaController::class, 'add'])->name('print_areas_add');
    Route::match(['get', 'post'], '/print_areas/edit/{id}', [PrintAreaController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('print_areas_edit');
    Route::get('/print_areas/info/{id}', [PrintAreaController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('print_areas_info');
    Route::match(['get', 'post'], '/print_areas/delete', [PrintAreaController::class, 'delete'])->name('print_areas_delete');
    Route::post('/print_areas/import', [PrintAreaController::class, 'import'])->name('print_areas_import');
    Route::get('/print_areas/export', [PrintAreaController::class, 'export'])->name('print_areas_export');

    //[東京都|〇〇駐輪場] 契約許容市区マスタ
    Route::match(['get', 'post'], '/contract_allowable_cities', [ContractAllowableCityController::class, 'list'])->name('contract_allowable_cities');
    Route::match(['get', 'post'], '/contract_allowable_cities/add', [ContractAllowableCityController::class, 'add'])->name('contract_allowable_cities_add');
    Route::match(['get', 'post'], '/contract_allowable_cities/edit/{id}', [ContractAllowableCityController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('contract_allowable_cities_edit');
    Route::get('/contract_allowable_cities/info/{id}', [ContractAllowableCityController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('contract_allowable_cities_info');
    Route::match(['get', 'post'], '/contract_allowable_cities/delete', [ContractAllowableCityController::class, 'delete'])->name('contract_allowable_cities_delete');
    Route::post('/contract_allowable_cities/import', [ContractAllowableCityController::class, 'import'])->name('contract_allowable_cities_import');
    Route::get('/contract_allowable_cities/export', [ContractAllowableCityController::class, 'export'])->name('contract_allowable_cities_export');
 
    //[東京都|〇〇駐輪場] 管駐輪場管理者マスタ
    Route::match(['get', 'post'], '/managers', [ManagerController::class, 'list'])->name('managers');
    Route::match(['get', 'post'], '/managers/add', [ManagerController::class, 'add'])->name('managers_add');
    Route::match(['get', 'post'], '/managers/edit/{id}', [ManagerController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('managers_edit');
    Route::get('/managers/info/{id}', [ManagerController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('managers_info');
    Route::match(['get', 'post'], '/managers/delete', [ManagerController::class, 'delete'])->name('managers_delete');
    Route::post('/managers/import', [ManagerController::class, 'import'])->name('managers_import');
    Route::get('/managers/export', [ManagerController::class, 'export'])->name('managers_export');

    // [東京都|〇〇駐輪場] 消費税マスタ
    Route::match(['get', 'post'], '/tax', [TaxController::class, 'list'])->name('tax');
    Route::match(['get', 'post'], '/tax/add', [TaxController::class, 'add'])->name('tax_add');
    Route::match(['get', 'post'], '/tax/edit/{id}', [TaxController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('tax_edit');
    Route::get('/tax/info/{id}', [TaxController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('tax_info');
    Route::match(['get', 'post'], '/tax/delete', [TaxController::class, 'delete'])->name('tax_delete');
    Route::post('/tax/import', [TaxController::class, 'import'])->name('tax_import');
    Route::get('/tax/export', [TaxController::class, 'export'])->name('tax_export');

    // [東京都|〇〇駐輪場] 決済情報マスタ
    Route::match(['get', 'post'], '/payments', [PaymentController::class, 'list'])->name('payments');
    Route::match(['get', 'post'], '/payments/add', [PaymentController::class, 'add'])->name('payments_add');
    Route::match(['get', 'post'], '/payments/edit/{id}', [PaymentController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('payments_edit');
    Route::get('/payments/info/{id}', [PaymentController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('payments_info');
    Route::match(['get', 'post'], '/payments/delete', [PaymentController::class, 'delete'])->name('payments_delete');
    Route::post('/payments/import', [PaymentController::class, 'import'])->name('payments_import');
    Route::get('/payments/export', [PaymentController::class, 'export'])->name('payments_export');

    // [東京都|〇〇駐輪場] 決済トランザクション
    Route::match(['get', 'post'], '/settlement_transactions', [SettlementTransactionController::class, 'list'])->name('settlement_transactions');
    Route::match(['get', 'post'], '/settlement_transactions/add', [SettlementTransactionController::class, 'add'])->name('settlement_transactions_add');
    Route::match(['get', 'post'], '/settlement_transactions/edit/{id}', [SettlementTransactionController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('settlement_transactions_edit');
    Route::get('/settlement_transactions/info/{id}', [SettlementTransactionController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('settlement_transactions_info');
    Route::match(['get', 'post'], '/settlement_transactions/delete', [SettlementTransactionController::class, 'delete'])->name('settlement_transactions_delete');
    Route::post('/settlement_transactions/import', [SettlementTransactionController::class, 'import'])->name('settlement_transactions_import');
    Route::get('/settlement_transactions/export', [SettlementTransactionController::class, 'export'])->name('settlement_transactions_export');

    // [東京都|〇〇駐輪場] オペレーターマスタ
    Route::match(['get', 'post'], '/opes', [OpeController::class, 'list'])->name('opes');
    Route::match(['get', 'post'], '/opes/add', [OpeController::class, 'add'])->name('opes_add');
    Route::match(['get', 'post'], '/opes/edit/{id}', [OpeController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('opes_edit');
    Route::get('/opes/info/{id}', [OpeController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('opes_info');
    Route::match(['get', 'post'], '/opes/delete', [OpeController::class, 'delete'])->name('opes_delete');
    Route::post('/opes/import', [OpeController::class, 'import'])->name('opes_import');
    Route::get('/opes/export', [OpeController::class, 'export'])->name('opes_export');

    // [東京都|〇〇駐輪場] デバイス管理マスタ
    Route::match(['get', 'post'], '/devices', [DeviceController::class, 'list'])->name('devices');
    Route::match(['get', 'post'], '/devices/add', [DeviceController::class, 'add'])->name('devices_add');
    Route::match(['get', 'post'], '/devices/edit/{id}', [DeviceController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('devices_edit');
    Route::get('/devices/info/{id}', [DeviceController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('devices_info');
    Route::match(['get', 'post'], '/devices/delete', [DeviceController::class, 'delete'])->name('devices_delete');
    Route::post('/devices/import', [DeviceController::class, 'import'])->name('devices_import');

    // [東京都|〇〇駐輪場] オペレータキュー
    Route::match(['get', 'post'], '/operator_ques', [OperatorQueController::class, 'list'])->name('operator_ques');
    Route::match(['get', 'post'], '/operator_ques/add', [OperatorQueController::class, 'add'])->name('operator_ques_add');
    Route::match(['get', 'post'], '/operator_ques/edit/{id}', [OperatorQueController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('operator_ques_edit');
    Route::get('/operator_ques/info/{id}', [OperatorQueController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('operator_ques_info');
    Route::match(['get', 'post'], '/operator_ques/delete', [OperatorQueController::class, 'delete'])->name('operator_ques_delete');
    Route::post('/operator_ques/import', [OperatorQueController::class, 'import'])->name('operator_ques_import');
    Route::get('/operator_ques/export', [OperatorQueController::class, 'export'])->name('operator_ques_export');

    // [東京都|〇〇駐輪場] 設定マスタ
    Route::match(['get', 'post'], '/settings', [SettingController::class, 'list'])->name('settings');
    Route::match(['get', 'post'], '/settings/add', [SettingController::class, 'add'])->name('settings_add');
    Route::match(['get', 'post'], '/settings/edit/{id}', [SettingController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('settings_edit');
    Route::get('/settings/info/{id}', [SettingController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('settings_info');
    Route::match(['get', 'post'], '/settings/delete', [SettingController::class, 'delete'])->name('settings_delete');
    Route::post('/settings/delete/{id}', [SettingController::class, 'delete'])
        ->where(['id' => '[0-9]+'])
        ->name('settings_delete_id');


    // [東京都|〇〇駐輪場] メール送信テンプレートマスタ
    Route::match(['get', 'post'], '/mail_templates', [MailTemplateController::class, 'list'])->name('mail_templates');
    Route::match(['get', 'post'], '/mail_templates/add', [MailTemplateController::class, 'add'])->name('mail_templates_add');
    Route::match(['get', 'post'], '/mail_templates/edit/{id}', [MailTemplateController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('mail_templates_edit');
    Route::get('/mail_templates/info/{id}', [MailTemplateController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('mail_templates_info');
    Route::match(['get', 'post'], '/mail_templates/delete', [MailTemplateController::class, 'delete'])->name('mail_templates_delete');
    Route::post('/mail_templates/import', [MailTemplateController::class, 'import'])->name('mail_templates_import');
    Route::get('/mail_templates/export', [MailTemplateController::class, 'export'])->name('mail_templates_export');

    // [東京都|〇〇駐輪場] インボイス設定マスタ
    Route::get('/inv_settings', [InvSettingController::class, 'list'])->name('inv_settings');
    Route::match(['get', 'post'], '/inv_settings/add', [InvSettingController::class, 'add'])->name('inv_settings_add');
    Route::match(['get', 'post'], '/inv_settings/edit/{id}', [InvSettingController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('inv_settings_edit');
    Route::post('/inv_settings/delete', [InvSettingController::class, 'delete'])->name('inv_settings_delete');
    Route::post('/inv_settings/upload', [InvSettingController::class, 'upload'])->name('inv_settings_upload');

    // [東京都|〇〇駐輪場] ゾーンマスタ
    Route::match(['get', 'post'], '/zones', [ZoneController::class, 'list'])->name('zones');
    Route::match(['get', 'post'], '/zones/add', [ZoneController::class, 'add'])->name('zones_add');
    Route::match(['get', 'post'], '/zones/edit/{id}', [ZoneController::class, 'edit'])
        ->where(['id' => '[0-9]+'])
        ->name('zones_edit');
    Route::match(['get', 'post'], '/zones/info/{id}', [ZoneController::class, 'info'])
        ->where(['id' => '[0-9]+'])
        ->name('zones_info');
    Route::match(['get', 'post'], '/zones/delete', [ZoneController::class, 'delete'])
        ->name('zones_delete');

    //kin end

    Route::get('/opes/{id}/permissions', [OpeController::class, 'getPermissionsByFeature'])
        ->where(['id' => '[0-9]+'])
        ->name('opes.permissions_by_feature');

    // 仮ルート（未実装機能用）
    Route::get('/placeholder', function () {
        return view('placeholder');
    })->name('placeholder');

    Route::get('/refund', function () {
        return view('placeholder');
    })->name('refund'); // SWA-13 返金処理
    
    Route::get('/tag-reissue', function () {
        return view('placeholder');
    })->name('tag.reissue'); // SWA-05 タグ再発行
    
    Route::get('/seal-reissue', function () {
        return view('placeholder');
    })->name('seal.reissue'); // SWA-06 シール再発行
    
    Route::get('/sales-report', function () {
        return view('placeholder');
    })->name('sales.report'); // SWA-17 売上年報／月報／日報
    
    Route::get('/sales-detail', function () {
        return view('placeholder');
    })->name('sales.detail'); // SWA-18 売上詳細
    
    Route::get('/ptype', function () {
        return view('placeholder');
    })->name('ptype'); // SWA-29 駐輪分類マスタ
    
    Route::get('/jurisdiction-parking', function () {
        return view('placeholder');
    })->name('jurisdiction.parking'); // SWA-37 駐輪規定読込記録
    
    Route::get('/lottery-master', function () {
        return view('placeholder');
    })->name('lottery.master'); // SWA-44 駐輪場抽選応募マスタ
    
    Route::get('/lottery-setting', function () {
        return view('placeholder');
    })->name('lottery.setting'); // SWA-45 抽選申込設定マスタ
    
    }); // ensure.otp.verified ミドルウェアグループの閉じ括弧
}); // auth ミドルウェアグループの閉じ括弧


// Wellnet PUSH webhook (SHJ-4A) 
// 外部からのウェルネット決済情報受信用エンドポイント

// 本番用SHJ-4A専用エンドポイント（外部からのPUSH通知受信）
Route::post('/shj4a', [App\Http\Controllers\Webhook\WellnetController::class, 'receive'])
    ->name('shj4a.webhook')
    ->withoutMiddleware(['auth', 'verified']); // 認証不要、外部アクセス用

// 開発・デバッグ用の既存エンドポイント（内部テスト用として保持）
Route::post('/webhook/wellnet', [App\Http\Controllers\Webhook\WellnetController::class, 'receive'])
    ->name('wellnet.webhook.receive')
    ->withoutMiddleware(['auth', 'verified']); // 認証不要

