<?php
use \App\Http\Controllers\admin\ServicesController;
use App\Http\Controllers\admin\CompaniesController;
use App\Http\Controllers\admin\UserController;
use App\Http\Controllers\HomeController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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!
|
*/


Route::get('/', [HomeController::class, 'index'])->name('home.page');

//Get States By Country Id
Route::get('states/{country_id}', [HomeController::class, 'statesByCountry']);

//Get Cities By State Id
Route::get('cities/{state_id}', [HomeController::class, 'citiesByCountry']);


Auth::routes();

/*Route::get('/login', function () {
    redirect()->route('home.page');
});*/

//Auth Routes
Route::group(['middleware' => 'auth'], function () {
    Route::get('dashboard', [HomeController::class, 'dashboard'])->name('dashboard');
    Route::any('business-directory-list', [CompaniesController::class, 'search'])->name('business-directory-list');
    Route::get('settings', [HomeController::class, 'settings'])->name('setting');
    Route::put('update-profile', [HomeController::class, 'updateProfile'])->name('update-profile');
    Route::post('update-wallet', [HomeController::class, 'updateUserWallet'])->name('update-user-wallet');

    //Admin Routes
    Route::group(['prefix' => 'admin'], function () {
        Route::get('/', function () {
            return view('admin.admin_template');
        });
        Route::resource('services', ServicesController::class);
        Route::resource('companies', CompaniesController::class);
        Route::resource('users', UserController::class);
        Route::post('order', [HomeController::class, 'order'])->name('order');

    });
});

