<?php

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

// 後台路由
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');
        // 範例: 動物園管理 > 老虎管理
        // 注意以下的路由全都不是 restful api 架構，請參照 controller 文件中的註解
        Route::get('/zooManagement/tigerManagement', 'ZooManagement\TigerManagementController@index');
        Route::get('/zooManagement/tigerManagement/create', 'ZooManagement\TigerManagementController@create');
        Route::get('/zooManagement/tigerManagement/edit/{id}', 'ZooManagement\TigerManagementController@edit');
        Route::post('/zooManagement/tigerManagement/store', 'ZooManagement\TigerManagementController@store');
        Route::delete('/zooManagement/tigerManagement/{id}', 'ZooManagement\TigerManagementController@delete');
    });
});