<?php

use App\Http\Controllers\Admin\AgentHero1Controller;
use App\Http\Controllers\Admin\AgentHero2Controller;
use App\Http\Controllers\Admin\AgentHeroController;
use App\Http\Controllers\Admin\BankHero1Controller;
use App\Http\Controllers\Admin\BankHowItWorkController;
use App\Http\Controllers\Admin\BankSectionController;
use App\Http\Controllers\Admin\BlogController;
use App\Http\Controllers\Admin\BlogHeroController;
use App\Http\Controllers\Admin\CareerHeroController;
use App\Http\Controllers\Admin\CategoryController;
use App\Http\Controllers\Admin\ClintReviewController;
use App\Http\Controllers\Admin\CompanyStateHeroController;
use App\Http\Controllers\Admin\GuideFaqController;
use App\Http\Controllers\Admin\HelpCenterController;
use App\Http\Controllers\Admin\HeroThreeController;
use App\Http\Controllers\Admin\HeroTwoController;
use App\Http\Controllers\Admin\HomeCompanyController;
use App\Http\Controllers\Admin\HomePageSettingController as AdminHomePageSettingController;
use App\Http\Controllers\Admin\InnovativecomoanieController;
use App\Http\Controllers\Admin\MailroomHeroController;
use App\Http\Controllers\Admin\PageController;
use App\Http\Controllers\Admin\PartnerHeroController;
use App\Http\Controllers\Admin\PartnerRulesController;
use App\Http\Controllers\Admin\ProfileController;
use App\Http\Controllers\ProfileController as UserProfileController;
use App\Http\Controllers\Admin\SettingController;
use App\Http\Controllers\Admin\PlatFormController;
use App\Http\Controllers\Admin\PlatformsController;
use App\Http\Controllers\Admin\PricingController;
use App\Http\Controllers\Admin\PricingHeroController;
use App\Http\Controllers\Admin\ProductController;
use App\Http\Controllers\Admin\RewardHeroController;
use App\Http\Controllers\Admin\StartSettingController;
use App\Http\Controllers\Admin\ToolController;
use App\Http\Controllers\Front\PriceController;
use App\Models\Blog;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Route;



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

// Route::get('pricing', function () {
//     return view('pricing');
// })->name('pricing');

Route::get('pricing',[PriceController::class,'index'])->name('pricing');
Route::get('start', function () {
    return view('start');
})->name('start');

Route::get('company-state', function () {
    return view('company-state');
})->name('company-state');
Route::get('review', function () {
    return view('review');
})->name('review');


Route::get('rewards', function () {
    return view('rewards');
})->name('rewards');

Route::get('partners', function () {
    return view('partners');
})->name('partners');
Route::get('blogs', function () {
    $blogs = Blog::all();

    return view('blogs',compact('blogs') );
})->name('blogs');
Route::get('about', function () {
    return view('about');
})->name('about');

Route::get('report', function () {
    return view('report');
})->name('report');

Route::get('guide', function () {
    return view('guide');
})->name('guide');

Route::get('help-center', function () {
    return view('front.help');
})->name('help');

Route::get('careers', function () {
    return view('careers');
})->name('careers');

Route::get('agent', function () {
    return view('agent');
})->name('agent');

Route::get('mailroom', function () {
    return view('mailroom');
})->name('mailroom');

Route::get('bank', function () {
    return view('bank');
})->name('bank');

Route::get('/admin', function () {
    return redirect()->route('admin.login');
});


Route::prefix('/dashboard')->group(function () {

    Route::get('/', function () {
        return view('front.dashboard');
    })->name('front.dashboard');
    Route::get('/billings', function () {
        return view('front.billing');
    })->name('front.billing');
    Route::get('/details', function () {
        return view('front.details');
    })->name('front.details');
    Route::get('/documents', function () {
        return view('front.documents');
    })->name('front.documents');
    Route::get('/agents', function () {
        return view('front.agents');
    })->name('front.agents');
    Route::get('/mailroom', function () {
        return view('front.mailroom');
    })->name('front.mailroom');

    Route::get('/banking', function () {
        return view('front.banking');
    })->name('front.banking');
    Route::get('/rewards', function () {
        return view('front.rewards');
    })->name('front.rewards');
    Route::get('/referral', function () {
        return view('front.referral');
    })->name('front.referral');
    Route::get('/account-setting', function () {
        return view('front.account-setting');
    })->name('front.account-setting');

    Route::get('/help', function () {
        return view('front.help');
    })->name('front.help');
});



Route::get('/storage-link', function () {
    Artisan::call('storage:link');
    return 'Success';
});

Route::get('/optimize', function () {
    Artisan::call('optimize:clear');
    return 'Success';
});

Route::get('/cache-clear', function () {
    Artisan::call('route:clear');
    Artisan::call('cache:clear');
    Artisan::call('config:clear');
    Artisan::call('view:clear');
    return 'Success';
});



// Route::get('/dashboard', function () {
//     return view('dashboard');
// })->middleware(['auth', 'verified'])->name('dashboard');


// Route::get('/dashboard', function () {
//     return view('front.dashboard');
// })->middleware(['front'])->name('dashboard');

// Route::get('/appoinment', function () {
//     return view('appoinment');
// })->name('appoinment');


Route::middleware('front')->group(function () {

    Route::get('/profile', [UserProfileController::class, 'edit'])->name('profile.edit');
    Route::post('/profile', [UserProfileController::class, 'frontuserInfoUpdate'])->name('profile.update');
    Route::delete('/profile', [UserProfileController::class, 'destroy'])->name('profile.destroy');

    Route::post('/change-password', [UserProfileController::class, 'frontuserChangePasswordUpdate'])->name('profile.password.change');
});


require __DIR__ . '/front_auth.php';

// admin

Route::get('/admin/dashboard', function () {
    return view('admin.dashboard');
})->middleware(['auth'])->name('admin.dashboard');




Route::namespace('App\Http\Controllers\Admin')->name('admin.')->prefix('admin')->middleware(['auth'])->group(function () {

    Route::resource('roles', 'RoleController');
    Route::resource('permissions', 'PermissionController');
    Route::resource('users', 'UserController');


    // Plat Form Controller
    Route::resource('platforms', PlatformsController::class);


    // Clear Everything
    Route::get('/route-clear-site', [SettingController::class, 'route_clear_site'])->name('route_clear_site');
    Route::get('/cache-clear-site', [SettingController::class, 'cache_clear_site'])->name('cache_clear_site');
    Route::get('/config-clear-site', [SettingController::class, 'config_clear_site'])->name('config_clear_site');
    Route::get('/view-clear-site', [SettingController::class, 'view_clear_site'])->name('view_clear_site');
    Route::get('/storage-link-site', [SettingController::class, 'storage_link_site'])->name('storage_link_site');



    // Pages
    Route::resource('pages', 'PageController');
    Route::get('pages-delete/{id}', [PageController::class, 'destroy'])->name('pages.destroy');

    // home page hero section
    Route::get('hero-section', [AdminHomePageSettingController::class, 'index'])->name('hero-section');
    Route::post('hero-section', [AdminHomePageSettingController::class, 'herosectionStore'])->name('herosectionStore');

    // home page company section
    Route::get('innovative-comoanies', [InnovativecomoanieController::class, 'index'])->name('inno-company.index');
    Route::get('innovative-comoanies/create', [InnovativecomoanieController::class, 'create'])->name('inno-company.create');
    Route::post('innovative-comoanies/store', [InnovativecomoanieController::class, 'store'])->name('inno-company.store');
    Route::get('innovative-comoanies/delete/{id}', [InnovativecomoanieController::class, 'delete'])->name('inno-company.delete');

    // home companys
    Route::resource('homecompany',HomeCompanyController::class);

    // hero two
    Route::get('hero-two', [HeroTwoController::class, 'index'])->name('herotwo.index');
    Route::post('hero-two/update', [HeroTwoController::class, 'update'])->name('herotwo.update');

    //hero three
    Route::get('hero-three', [HeroThreeController::class, 'index'])->name('herothree.index');
    Route::post('hero-three/update', [HeroThreeController::class, 'update'])->name('herothree.update');


    // tool image
    Route::get('tool', [ToolController::class, 'index'])->name('tool.index');
    Route::get('tool/create', [ToolController::class, 'create'])->name('tool.create');
    Route::post('tool/store', [ToolController::class, 'store'])->name('tool.store');
    Route::get('tool/delete/{id}', [ToolController::class, 'delete'])->name('tool.delete');

    //clint image
    Route::get('clint-review', [ClintReviewController::class, 'index'])->name('review.index');
    Route::post('clint-review', [ClintReviewController::class, 'update'])->name('review.update');



    //bank setting
    // hero section 1
    Route::get('bank-hero', [BankHero1Controller::class, 'index'])->name('bank.hero1');
    Route::post('bank-hero', [BankHero1Controller::class, 'update'])->name('bank.hero1updae');

    //how it work
    Route::get('bank-how-it-work', [BankHowItWorkController::class, 'index'])->name('bank-how-it-work');
    Route::get('bank-how-it-work/create', [BankHowItWorkController::class, 'create'])->name('bank-how-it-work.create');
    Route::get('bank-how-it-work/edit/{id}', [BankHowItWorkController::class, 'edit'])->name('bank-how-it-work.edit');
    Route::post('bank-how-it-work/update/{id}', [BankHowItWorkController::class, 'update'])->name('bank-how-it-work.update');
    Route::post('bank-how-it-work', [BankHowItWorkController::class, 'store'])->name('bank-how-it-workstore');
    Route::get('bank-how-it-work/delete/{id}', [BankHowItWorkController::class, 'delete'])->name('bank-how-it-work.delete');

    // banksection
    Route::resource('banksection', BankSectionController::class);

    Route::get('pricing-hero', [PricingHeroController::class, 'index'])->name('pricing-hero');
    Route::post('pricing-hero', [PricingHeroController::class, 'update'])->name('pricing-hero.update');

    Route::get('reward-hero', [RewardHeroController::class, 'index'])->name('rewardhero.index');
    Route::post('reward-hero', [RewardHeroController::class, 'update'])->name('rewardhero.update');

    Route::get('partner-hero', [PartnerHeroController::class, 'index'])->name('partner.index');
    Route::post('partner-hero', [PartnerHeroController::class, 'update'])->name('partner.update');

    // Route::get('partners-rules',[PartnerRulesController::class,'index']);
    Route::resource('partnerrules', PartnerRulesController::class);

    Route::get('blogs-hero', [BlogHeroController::class, 'index'])->name('bloghero.index');
    Route::post('blogs-hero', [BlogHeroController::class, 'update'])->name('bloghero.update');


    Route::get('mailroom-hero', [MailroomHeroController::class, 'index'])->name('mailroomhero.index');
    Route::post('mailroom-hero', [MailroomHeroController::class, 'update'])->name('mailroomhero.update');

    //Email Configurations
    Route::resource('email-configurations', 'SmtpController');

    Route::get('agent-hero',[AgentHeroController::class,'index'])->name('agent.hero.index');
    Route::post('agent-hero',[AgentHeroController::class,'update'])->name('agent.hero.update');

    Route::get('agent-hero2',[AgentHero2Controller::class,'index'])->name('agent.hero2.index');
    Route::post('agent-hero2',[AgentHero2Controller::class,'store'])->name('agent.hero2.store');

    // guide faq
    Route::get('guide-faq',[GuideFaqController::class,'index'])->name('guide.faq.index');
    Route::post('guide-faq',[GuideFaqController::class,'update'])->name('guide.faq.update');

    //company state
    Route::get('company-state-hero',[CompanyStateHeroController::class,'index'])->name('company.statehero.index');
    Route::post('company-state-hero',[CompanyStateHeroController::class,'update'])->name('company.statehero.update');

    // help center
    Route::resource('helpcenter',HelpCenterController::class);

    //career
    Route::get('career-hero',[CareerHeroController::class,'index'])->name('career.hero.index');
    Route::post('career-hero',[CareerHeroController::class,'update'])->name('career.hero.update');

    //category

    Route::resource('category',CategoryController::class);

    //blog
    Route::resource('blog',BlogController::class);


    //Settings
    Route::resource('general-settings', 'SettingController');
    Route::get('cache-clear', [SettingController::class, 'cache_clear'])->name('cache_clear');
    Route::get('database-backup', [SettingController::class, 'database_backup'])->name('database_backup');
    Route::get('database-generate', [SettingController::class, 'database_generate'])->name('database.generate');

    //products
    Route::resource('product',ProductController::class);


    Route::resource('startSetting',StartSettingController::class);

    Route::resource('pricing',PricingController::class);
    Route::get('delete-includes/{id}',[PricingController::class,'deleteIncludes'])->name('deleteincludes');

    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});


require __DIR__ . '/admin_auth.php';


Route::get('demo', function () {
    // return bank_how_it_works();
    return choose_partners();
});
