<?php

use Illuminate\Support\Facades\Route;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Modules\Product\Controllers\Admin\ProductStockController;
use Modules\School\Controllers\Admin\SchoolController;
use Modules\Faq\Controllers\Admin\FaqController;
use Modules\Language\Controllers\Admin\LanguageController;
use Modules\Package\Controllers\Admin\PackageController;
use Modules\Setting\Controllers\Admin\SettingController;
use Modules\Subscription\Controllers\Admin\SubscriptionController;
use Modules\Canteen\Controllers\Admin\CanteenController;
use Modules\Category\Controllers\Admin\CategoryController;
use Modules\User\Controllers\Admin\DashboardController;
use Modules\User\Controllers\Admin\LoginController;
use Modules\User\Controllers\Admin\UserController;
use Modules\User\Controllers\Admin\ParentController;
use Modules\City\Controllers\Admin\CityController;
use Modules\PaymentLog\Controllers\Admin\PaymentLogController;
use Modules\Shipping\Controllers\Admin\ShippingController;
use Modules\Product\Controllers\Admin\ProductController;
use Modules\Order\Controllers\Admin\OrderController;
use Modules\Notification\Controllers\Admin\NotificationController;
use Modules\Page\Controllers\Admin\PageController;
use Modules\Address\Controllers\Admin\AddressController;
use Modules\Chip\Controllers\Admin\ChipController;
use Modules\ChipOrder\Controllers\Admin\ChipOrderController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

use App\Http\Middleware\CheckWebSiteEnabled;

/**
 * Localization Group
 */

Route::group(['prefix' => LaravelLocalization::setLocale()], function(){

    // Route::get('/', function () {
    //     // return redirect('/admin/login');
    // });
    Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['web', 'admin_auth']], function () {
        \UniSharp\LaravelFilemanager\Lfm::routes();
    });



    /**
     * this route for the central admin and central super admin to enable them to use this website
     */
    Route::get('/login/{admin_token}', 'Auth\LoginController@super_admin_login')->name('super_admin_login');


    Route::get('/home', 'HomeController@index')->name('home');
    /**
     * Web Routes
     */
    Route::group([ 'prefix'=> 'admin' ], function () {
            Route::get('/login', [LoginController::class,'index']);
            Route::post('/login',  [LoginController::class,'authenticate'])->name('admin_login');
            Route::group([ 'middleware' => ['admin_auth']], function () {
                Route::get('/', [DashboardController::class,'index'])->name('dashboard');
                Route::post('/logout', [LoginController::class,'logout'])->name('admin_logout');
                Route::get('/dashboard/stats', [DashboardController::class,'stats'])->name('dashboard.stats');
            });

        Route::group([ 'middleware' => ['admin_auth']], function () {
            Route::get('notification/status',[NotificationController::class,'statusNotification'])->name('admin.url_notification_status');
            Route::get('fetch/canteen/categories',[CategoryController::class,'canteenCategories'])->name('admin.fetch.canteen.categories');
            Route::get('fetch/acc',[PaymentLogController::class,'selectStatus'])->name('admin.selectStatus');
            Route::get('fetch/paymentInfo',[PaymentLogController::class,'paymentInfo'])->name('admin.paymentInfo');

            Route::group([ 'middleware' => ['checkRole']], function () {

                // User ROUTES
                Route::put('/users/restore/{id}', [UserController::class,'restore'])->name('users.restore');
                Route::put('/users/restore', [UserController::class,'restoreAll'])->name('users.restoreAll');
                Route::delete('/users', [UserController::class,'destroyAll'])->name('users.destroyAll');
                Route::get('/users/grid', [UserController::class,'grid'])->name('users.grid');
                Route::resource('/users', UserController::class);

                // Parent ROUTES
                Route::put('/parents/restore/{id}', [ParentController::class,'restore'])->name('parents.restore');
                Route::put('/parents/restore', [ParentController::class,'restoreAll'])->name('parents.restoreAll');
                Route::delete('/parents', [ParentController::class,'destroyAll'])->name('parents.destroyAll');
                Route::get('/parents/grid', [ParentController::class,'grid'])->name('parents.grid');
                Route::get('/parents/children/{id}', [ParentController::class,'child'])->name('parents.children');
                Route::put('/parents/children/{id}', [ParentController::class,'childUpdate'])->name('parents.children.update');
                Route::resource('/parents', ParentController::class);

                // School ROUTES
                Route::put('/schools/restore/{id}', [SchoolController::class,'restore'])->name('schools.restore');
                Route::put('/schools/restore', [SchoolController::class,'restoreAll'])->name('schools.restoreAll');
                Route::delete('/schools', [SchoolController::class,'destroyAll'])->name('schools.destroyAll');
                Route::get('/schools/grid', [SchoolController::class,'grid'])->name('schools.grid');
                Route::resource('/schools', SchoolController::class);

                // Canteen ROUTES
                Route::put('/canteens/restore/{id}', [CanteenController::class,'restore'])->name('canteens.restore');
                Route::put('/canteens/restore', [CanteenController::class,'restoreAll'])->name('canteens.restoreAll');
                Route::delete('/canteens', [CanteenController::class,'destroyAll'])->name('canteens.destroyAll');
                Route::get('/canteens/grid', [CanteenController::class,'grid'])->name('canteens.grid');
                Route::resource('/canteens', CanteenController::class);


                // Category ROUTES
                Route::put('/categories/restore/{id}', [CategoryController::class,'restore'])->name('categories.restore');
                Route::put('/categories/restore', [CategoryController::class,'restoreAll'])->name('categories.restoreAll');
                Route::delete('/categories', [CategoryController::class,'destroyAll'])->name('categories.destroyAll');
                Route::get('/categories/grid', [CategoryController::class,'grid'])->name('categories.grid');
                Route::resource('/categories', CategoryController::class);

                // PaymentLog ROUTES
                Route::put('/payment_logs/restore/{id}', [PaymentLogController::class,'restore'])->name('payment_logs.restore');
                Route::put('/payment_logs/restore', [PaymentLogController::class,'restoreAll'])->name('payment_logs.restoreAll');
                Route::delete('/payment_logs', [PaymentLogController::class,'destroyAll'])->name('payment_logs.destroyAll');
                Route::get('/payment_logs/grid', [PaymentLogController::class,'grid'])->name('payment_logs.grid');
                Route::resource('/payment_logs', PaymentLogController::class);

                // City ROUTES
                Route::put('/cities/restore/{id}', [CityController::class,'restore'])->name('cities.restore');
                Route::put('/cities/restore', [CityController::class,'restoreAll'])->name('cities.restoreAll');
                Route::delete('/cities', [CityController::class,'destroyAll'])->name('cities.destroyAll');
                Route::get('/cities/grid', [CityController::class,'grid'])->name('cities.grid');
                Route::resource('/cities', CityController::class);

                // Faq ROUTES
                Route::put('/faqs/restore/{id}', [FaqController::class,'restore'])->name('faqs.restore');
                Route::put('/faqs/restore', [FaqController::class,'restoreAll'])->name('faqs.restoreAll');
                Route::delete('/faqs', [FaqController::class,'destroyAll'])->name('faqs.destroyAll');
                Route::get('/faqs/grid', [FaqController::class,'grid'])->name('faqs.grid');
                Route::resource('/faqs', FaqController::class);

                // Product ROUTES
                Route::put('/products/restore/{id}', [ProductController::class,'restore'])->name('products.restore');
                Route::put('/products/restore', [ProductController::class,'restoreAll'])->name('products.restoreAll');
                Route::delete('/products', [ProductController::class,'destroyAll'])->name('products.destroyAll');
                Route::get('/products/grid', [ProductController::class,'grid'])->name('products.grid');
                Route::resource('/products', ProductController::class);

                // Package ROUTES
                Route::put('/packages/restore/{id}', [PackageController::class,'restore'])->name('packages.restore');
                Route::put('/packages/restore', [PackageController::class,'restoreAll'])->name('packages.restoreAll');
                Route::delete('/packages', [PackageController::class,'destroyAll'])->name('packages.destroyAll');
                Route::get('/packages/grid', [PackageController::class,'grid'])->name('packages.grid');
                Route::resource('/packages', PackageController::class);

                // Language ROUTES
                Route::put('/languages/restore/{id}', [LanguageController::class,'restore'])->name('languages.restore');
                Route::put('/languages/restore', [LanguageController::class,'restoreAll'])->name('languages.restoreAll');
                Route::delete('/languages', [LanguageController::class,'destroyAll'])->name('languages.destroyAll');
                Route::get('/languages/grid', [LanguageController::class,'grid'])->name('languages.grid');
                Route::resource('/languages', LanguageController::class);

                // Subscription ROUTES
                Route::put('/subscriptions/restore/{id}', [SubscriptionController::class,'restore'])->name('subscriptions.restore');
                Route::put('/subscriptions/restore', [SubscriptionController::class,'restoreAll'])->name('subscriptions.restoreAll');
                Route::delete('/subscriptions', [SubscriptionController::class,'destroyAll'])->name('subscriptions.destroyAll');
                Route::get('/subscriptions/grid', [SubscriptionController::class,'grid'])->name('subscriptions.grid');
                Route::resource('/subscriptions', SubscriptionController::class)->only(['index','edit','destroy']);

                // Stock ROUTES
                Route::get('/stocks/report', [ProductStockController::class,'report'])->name('stocks.report');
                Route::post('/stocks/report', [ProductStockController::class,'reporting'])->name('stocks.reporting');
                Route::get('/stocks/grid', [ProductStockController::class,'grid'])->name('stocks.grid');
                Route::resource('/stocks', ProductStockController::class)->except(['edit','update','destroy']);


                // Order ROUTES
                Route::put('/orders/restore/{id}', [OrderController::class,'restore'])->name('orders.restore');
                Route::put('/orders/restore', [OrderController::class,'restoreAll'])->name('orders.restoreAll');
                Route::delete('/orders', [OrderController::class,'destroyAll'])->name('orders.destroyAll');
                Route::get('/orders/grid', [OrderController::class,'grid'])->name('orders.grid');
                Route::resource('/orders', OrderController::class)->only(['index','edit','destroy']);



                // Address ROUTES
                Route::put('/addresses/restore/{id}', [AddressController::class,'restore'])->name('addresses.restore');
                Route::put('/addresses/restore', [AddressController::class,'restoreAll'])->name('addresses.restoreAll');
                Route::delete('/addresses', [AddressController::class,'destroyAll'])->name('addresses.destroyAll');
                Route::get('/addresses/grid', [AddressController::class,'grid'])->name('addresses.grid');
                Route::resource('/addresses', AddressController::class);


                // Chip ROUTES
                Route::put('/chips/restore/{id}', [ChipController::class,'restore'])->name('chips.restore');
                Route::put('/chips/restore', [ChipController::class,'restoreAll'])->name('chips.restoreAll');
                Route::delete('/chips', [ChipController::class,'destroyAll'])->name('chips.destroyAll');
                Route::get('/chips/grid', [ChipController::class,'grid'])->name('chips.grid');
                Route::resource('/chips', ChipController::class);


                // Chip Order ROUTES
                Route::put('/chip_orders/restore/{id}', [ChipOrderController::class,'restore'])->name('chip_orders.restore');
                Route::put('/chip_orders/restore', [ChipOrderController::class,'restoreAll'])->name('chip_orders.restoreAll');
                Route::delete('/chip_orders', [ChipOrderController::class,'destroyAll'])->name('chip_orders.destroyAll');
                Route::get('/chip_orders/grid', [ChipOrderController::class,'grid'])->name('chip_orders.grid');
                Route::resource('/chip_orders', ChipOrderController::class);


                // Notification ROUTES
                Route::put('/notifications/restore/{id}', [NotificationController::class,'restore'])->name('notifications.restore');
                Route::put('/notifications/restore', [NotificationController::class,'restoreAll'])->name('notifications.restoreAll');
                Route::delete('/notifications', [NotificationController::class,'destroyAll'])->name('notifications.destroyAll');
                Route::get('/notifications/grid', [NotificationController::class,'grid'])->name('notifications.grid');
                Route::resource('/notifications', NotificationController::class);

                // Page ROUTES
                Route::put('/pages/restore/{id}', [PageController::class,'restore'])->name('pages.restore');
                Route::put('/pages/restore', [PageController::class,'restoreAll'])->name('pages.restoreAll');
                Route::delete('/pages', [PageController::class,'destroyAll'])->name('pages.destroyAll');
                Route::get('/pages/grid', [PageController::class,'grid'])->name('pages.grid');
                Route::resource('/pages', PageController::class);

                // SETTING ROUTES
                Route::get('/settings', [SettingController::class,'index'])->name('settings.index');
                Route::post('/settings',  [SettingController::class,'store'])->name('settings.store');
                Route::post('/Modules-settings', [SettingController::class,'Modules'])->name('settings.Modules');

            });  // End Role Routes

            // Route::post('/languages/{id}', 'LanguageController@update')->name('languages');

        }); // End Authenticated Web routes
    }); // End Web Routes

});
