<?php

Route::get('/', function () {
    return view('welcome');
});

// API 路由
Route::group(['prefix' => 'api', 'namespace' => 'Api'], function () {
    Route::post('/inner/store', 'GeneralInnerServiceController@store');
    Route::get('/inner/fetch', 'GeneralInnerServiceController@fetch');
    Route::get('/inner/fetchById', 'GeneralInnerServiceController@fetchById');
    Route::get('/inner/qrcode/{code}', 'GeneralInnerServiceController@qrcode');
    Route::get('/inner/dateseg', 'GeneralInnerServiceController@dateseg');
});

// 後台路由
Route::group(['middleware' => 'web', 'prefix' => 'backend'], function () {
    Route::auth();
    Route::group(['middleware' => 'auth', 'namespace' => 'Backend'], function () {
        // 後台相關的路由請設置在這裡，將包含權限驗證
        Route::get('/', ['as' => 'backend.index', 'uses' => 'IndexController@index']);
        // 登出
        Route::post('/logout', function () {
            Auth::logout();
            
            return redirect('/backend');
        });
        // System ManagementChange Password
        Route::get('/Password', 'PasswordController@index');
        Route::post('/Password', 'PasswordController@update');
        // System ManagementManage Groups
        Route::get('/Usergroups', 'UsergroupsController@index');
        Route::get('/Usergroups/create', 'UsergroupsController@create');
        Route::get('/Usergroups/edit/{id}', 'UsergroupsController@edit');
        Route::post('/Usergroups/store', 'UsergroupsController@store');
        Route::delete('/Usergroups/{id}', 'UsergroupsController@delete');
        // System ManagementManage Users
        Route::get('/Users', 'UsersController@index');
        Route::get('/Users/edit/{id}', 'UsersController@edit');
        Route::get('/Users/create', 'UsersController@create');
        Route::post('/Users/store', 'UsersController@store');
        Route::delete('/Users/{id}', 'UsersController@delete');
        // System ManagementManage Functions
        Route::get('/Funmenus', 'FunmenusController@index');
        Route::get('/Funmenus/create', 'FunmenusController@create');
        Route::get('/Funmenus/edit/{id}', 'FunmenusController@edit');
        Route::post('/Funmenus/store', 'FunmenusController@store');
        Route::delete('/Funmenus/delete/{id}', 'FunmenusController@delete');
        // System ManagementManage Functions Detail
        Route::get('/Funmenus/{menuid}', 'FunmenusDetailController@index');
        Route::get('/Funmenus/{menuid}/create', 'FunmenusDetailController@create');
        Route::get('/Funmenus/{menuid}/edit/{id}', 'FunmenusDetailController@edit');
        Route::post('/Funmenus/{menuid}/store', 'FunmenusDetailController@store');
        Route::delete('/Funmenus/{menuid}/delete/{id}', 'FunmenusDetailController@delete');
        // 業務工具 > 網址管理
        Route::get('/dataManagement/urlManagement', 'DataManagement\UrlManagementController@index');
        Route::get('/dataManagement/urlManagement/grid', 'DataManagement\UrlManagementController@grid');
        Route::get('/dataManagement/urlManagement/qrcode/{code}', 'DataManagement\UrlManagementController@qrcode');
        Route::get('/dataManagement/urlManagement/create', 'DataManagement\UrlManagementController@create');
        Route::get('/dataManagement/urlManagement/edit/{id}', 'DataManagement\UrlManagementController@edit');
        Route::post('/dataManagement/urlManagement/store', 'DataManagement\UrlManagementController@store');
        Route::post('/dataManagement/urlManagement/export', 'DataManagement\UrlManagementController@export');
    });
});