<?php

/*
|--------------------------------------------------------------------------
| 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\Controllers\Admin\AdmobSettingController;
use App\Http\Controllers\Admin\AnalyticsReportController;
use App\Http\Controllers\Admin\App_SettingController;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Artisan;
use App\Http\Controllers\Admin\LoginController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Admin\CommentController;
use App\Http\Controllers\Admin\CompanyController;
use App\Http\Controllers\Admin\PageController;
use App\Http\Controllers\Admin\ServiceController;
use App\Http\Controllers\Admin\ComplaintController;
use App\Http\Controllers\Admin\DepartmentController;
use App\Http\Controllers\Admin\FaceBookAdsSettingController;
use App\Http\Controllers\Admin\GeoAnalyticsController;
use App\Http\Controllers\Admin\HashtagController;
use App\Http\Controllers\Admin\InActiveInChargeController;
use App\Http\Controllers\Admin\InactiveSubInChargeController;
use App\Http\Controllers\Admin\InChargeController;
use App\Http\Controllers\Admin\LiveRequestController;
use App\Http\Controllers\Admin\NotificationConfigurationsController;
use App\Http\Controllers\Admin\NotificationController;
use App\Http\Controllers\Admin\PanelSettingController;
use App\Http\Controllers\Admin\ProfileController;
use App\Http\Controllers\Admin\StoryController;
use App\Http\Controllers\Admin\SubInChargeController;
use App\Http\Controllers\Admin\SystemSettingController;
use App\Http\Controllers\Admin\UserPageController;
use App\Http\Controllers\Admin\VacancyController;

// Artisan
Route::get('artisan', function () {

    Artisan::call('config:clear');
    Artisan::call('config:cache');
    Artisan::call('cache:clear');
    Artisan::call('view:clear');
    Artisan::call('route:clear');
    return "<h1>All Config Cache Clear Successfully.</h1>";
});

// Version
Route::get('version', function () {
    return "<h1>
        <li>PHP : " . phpversion() . "</li>
        <li>Laravel : " . app()->version() . "</li>
    </h1>";
});

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

    // Login-Logout
    Route::get('login', [LoginController::class, 'login'])->name('admin.login');
    Route::post('login', [LoginController::class, 'save_login'])->name('admin.save.login');
    Route::get('logout', [LoginController::class, 'logout'])->name('admin.logout');
    Route::any('SaveChunkstory', [StoryController::class, 'SaveChunkstory']);

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

        // Dashboard
        Route::get('dashboard', [DashboardController::class, 'index'])->name('admin.dashboard');
        Route::get('language', [DashboardController::class, 'language'])->name('language');
        // Live Request
        Route::resource('live_request', LiveRequestController::class)->only(['index']);
        // Profile
        Route::resource('profile', ProfileController::class)->only(['index', 'store']);
        Route::post('profile/changepassword', [ProfileController::class, 'ChangePassword'])->name('profile.changepassword');
        // Hashtag
        Route::resource('hashtag', HashtagController::class)->only(['index', 'store', 'update', 'show']);
        // User
        Route::resource('user', UserController::class)->only(['index', 'create', 'store', 'edit', 'update']);
        Route::get('user/address/{id}', [UserController::class, 'AddressIndex'])->name('user.address.index');
        Route::post('user/address/store', [UserController::class, 'AddressStore'])->name('user.address.store');
        Route::post('user/address/update', [UserController::class, 'AddressUpdate'])->name('user.address.update');
        Route::post('user/address/status/{id}', [UserController::class, 'AddressStatus'])->name('user.address.status');
        // Company
        Route::resource('company', CompanyController::class)->only(['index', 'create', 'store', 'edit', 'update']);
        // Vacancy
        Route::resource('vacancy', VacancyController::class)->only(['index', 'create', 'store', 'show', 'edit', 'update']);
        Route::post('vacancy/get_comapny', [VacancyController::class, 'get_comapny'])->name('get_comapny');
        // In Charge
        Route::resource('in_charge', InChargeController::class)->only(['index', 'store', 'update']);
        Route::post('in_charge/transfer', [InChargeController::class, 'transfer_incharge'])->name('in_charge.transfer');
        // Departmenthead
        Route::resource('department', DepartmentController::class)->only(['index', 'create', 'store', 'show', 'edit', 'update']);
        Route::post('department/sortorder', [DepartmentController::class, 'SortOrder'])->name('department.sortorder');
        Route::get('department/service/{id}', [DepartmentController::class, 'service_index'])->name('department.service.index');
        Route::post('department/service/save', [DepartmentController::class, 'service_store'])->name('department.service.store');
        Route::post('department/service/update', [DepartmentController::class, 'service_update'])->name('department.service.update');
        // InActive In Charge
        Route::resource('inactive_incharge', InActiveInChargeController::class)->only(['index']);
        // Service
        Route::resource('service', ServiceController::class)->only(['index', 'store', 'update', 'show']);
        Route::post('service/sortorder', [ServiceController::class, 'SortOrder'])->name('service.sortorder');
        // Sub In-Charge
        Route::resource('sub_incharge', SubInChargeController::class)->only(['index', 'create', 'store', 'edit', 'update', 'show']);
        Route::post('all_service', [SubInChargeController::class, 'all_service'])->name('all_service');
        Route::post('sub_incharge/transfer', [SubInChargeController::class, 'transfer_sub_incharge'])->name('sub_incharge.transfer');
        // InActive Sub In-Charge
        Route::resource('inactive_sub_incharge', InactiveSubInChargeController::class)->only(['index']);
        // complaint
        Route::resource('complaint', ComplaintController::class)->only(['index']);
        Route::get('complaint/request_index/{id}', [ComplaintController::class, 'request_index'])->name('complaint.request_index');
        Route::get('complaint/details/{id}', [ComplaintController::class, 'complaintDetails'])->name('complaint.details');
        Route::post('complaint/details/update', [ComplaintController::class, 'complaintDetailsUpdate'])->name('complaint.details.update');
        Route::post('complaint/image/save', [ComplaintController::class, 'complaint_after_image'])->name('complaint.image.save');
        // Story
        Route::resource('story', StoryController::class)->only(['index', 'create', 'store', 'edit', 'update']);
        // User Pages
        Route::resource('userpages', UserPageController::class)->only(['index', 'create', 'store', 'edit', 'update', 'show']);
        Route::post('userpages/layout', [PageController::class, 'layout'])->name('userpages.layout');
        // Pages
        Route::resource('pages', PageController::class)->only(['index', 'create', 'store', 'edit', 'update', 'show']);
        Route::post('pages/layout', [PageController::class, 'layout'])->name('pages.layout');
        // Notification
        Route::resource('notification', NotificationController::class)->only(['index', 'create', 'store']);
        Route::get('notifications/setting', [NotificationController::class, 'setting'])->name('notification.setting');
        // Comment
        Route::resource('comment', CommentController::class)->only(['index', 'show']);
        // App Setting
        Route::get('appsetting', [App_SettingController::class, 'index'])->name('app.setting');
        Route::post('appsetting/save', [App_SettingController::class, 'app_setting_save'])->name('app.setting.save');
        Route::post('appsetting/smtp', [App_SettingController::class, 'app_setting_smtp'])->name('app.setting.smtp');
        Route::post('appsetting/onboarding_screen', [App_SettingController::class, 'app_setting_onboarding_screen'])->name('app.setting.onboarding_screen');
        Route::post('appsetting/social_link', [App_SettingController::class, 'app_setting_social_link'])->name('app.setting.social_link');
        Route::post('setting/google_map_key', [App_SettingController::class, 'google_map_key'])->name('setting.google_map_key');
        Route::post('setting/vapidkey', [App_SettingController::class, 'vapIdKey'])->name('setting.vapidkey');
        // Admob
        Route::resource('admob', AdmobSettingController::class)->only(['index']);
        Route::post('admob/status', [AdmobSettingController::class, 'admobStatus'])->name('admob.status');
        Route::post('admob/android', [AdmobSettingController::class, 'admobAndroid'])->name('admob.android');
        Route::post('admob/ios', [AdmobSettingController::class, 'admobIos'])->name('admob.ios');
        // FaceBook Ads
        Route::resource('fbads', FaceBookAdsSettingController::class)->only(['index']);
        Route::post('fbads/status', [FaceBookAdsSettingController::class, 'facebookadStatus'])->name('fbads.status');
        Route::post('fbads/android', [FaceBookAdsSettingController::class, 'facebookadAndroid'])->name('fbads.android');
        Route::post('fbads/ios', [FaceBookAdsSettingController::class, 'facebookadIos'])->name('fbads.ios');
        // System Setting
        Route::get('systemsetting', [SystemSettingController::class, 'index'])->name('system.setting.index');
        Route::post('systemsetting/cleardata', [SystemSettingController::class, 'ClearData'])->name('system.setting.cleardata');
        Route::post('systemsetting/cleandatabase', [SystemSettingController::class, 'CleanDatabase'])->name('system.setting.cleandatabase');
        // Panel Setting
        Route::get('panelsetting', [PanelSettingController::class, 'index'])->name('panelsetting.index');
        Route::post('panelsetting/save', [PanelSettingController::class, 'save'])->name('panelsetting.save');
        // Notification Configurations
        Route::resource('notification-configurations', NotificationConfigurationsController::class)->only(['index', 'store']);
        // Analytics & Report
        Route::resource('analytics-report', AnalyticsReportController::class)->only(['index']);
        // Geo Analytics
        Route::resource('geo_analytics', GeoAnalyticsController::class)->only(['index']);

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

            // Category
            Route::resource('service', ServiceController::class)->only(['destroy']);
            // Department
            Route::resource('department', DepartmentController::class)->only(['destroy']);
            Route::delete('department/service/{department_id}/{id}', [DepartmentController::class, 'service_delete'])->name('department.service.delete');
            // Hashtag
            Route::resource('hashtag', HashtagController::class)->only(['destroy']);
            // User
            Route::resource('user', UserController::class)->only(['destroy']);
            Route::post('user/address/delete/{user_id}/{id}', [UserController::class, 'AddressDelete'])->name('user.address.delete');
            // Company
            Route::resource('company', CompanyController::class)->only(['destroy']);
            // Vacancy
            Route::resource('vacancy', VacancyController::class)->only(['destroy']);
            // In Charge
            Route::resource('in_charge', InChargeController::class)->only(['destroy']);
            // Sub In-Charge
            Route::resource('sub_incharge', SubInChargeController::class)->only(['destroy']);
            // complaint
            Route::resource('complaint', ComplaintController::class)->only(['destroy']);
            // Story
            Route::resource('story', StoryController::class)->only(['show']);
            // Notification
            Route::resource('notification', NotificationController::class)->only(['destroy']);
            Route::post('notifications/setting', [NotificationController::class, 'settingsave'])->name('notification.settingsave');
            // System Setting
            Route::get('systemsetting/downloadsqlfile', [SystemSettingController::class, 'DownloadSqlFile'])->name('system.setting.downloadsqlfile');
        });
    });
});
