<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\accounts;
use App\Http\Controllers\Dashboard;
use App\Http\Controllers\settings;
use App\Http\Controllers\drivers;
use App\Http\Controllers\drivers\driverdashboard;
use App\Http\Controllers\vehicles\vehicles;
use App\Http\Controllers\customers\customers;

/*
|--------------------------------------------------------------------------
| 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('/', function () {
    return view('welcome');
});

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

require __DIR__.'/auth.php';

//dashboard route
Route::group(['dashboard','middleware'=>['auth']],function(){
    Route::get('dashboard',[Dashboard::class,'index'])->name('dashboard');
    Route::get('autocomplete-search',[Dashboard::class,'autocompleteSearch']);
    Route::get('autocomplete-customer',[Dashboard::class,'autocompletecustomer']);
    Route::post('getcustomeremail',[Dashboard::class,'getcustomeremail'])->name('getcustomeremail');
    Route::get('autocomplete-driver',[Dashboard::class,'autocompletedriver']);
    Route::post('getdriverid',[Dashboard::class,'getdriverid'])->name('getdriverid');
    Route::post('checkroutes',[Dashboard::class,'checkroutes'])->name('checkroutes');
    Route::post('validatepin',[Dashboard::class,'validatepin'])->name('validatepin');
    Route::post('savebooking',[Dashboard::class,'savebooking'])->name('savebooking');
});

//account routes
Route::group(['accounts','middleware'=>['auth']],function(){
    Route::get('accounts',[accounts::class,'index'])->name('accounts');
    Route::get('maintain_accounts',[accounts::class,'maintain_accounts'])->name('maintain_accounts');
    Route::post('maintain_accounts',[accounts::class,'save_accounts'])->name('save_accounts');
});

//driver routes
Route::group(['drivers','middleware'=>['auth']],function(){
    Route::get('drivers',[drivers::class,'index'])->name('drivers');
    Route::get('maintain_driver',[drivers::class,'maintain_driver'])->name('maintain_driver');
    Route::post('maintain_driver',[drivers::class,'save_drivers'])->name('save_drivers');
    Route::get('autocomplete_driver_vehicle',[drivers::class,'autocomplete_driver_vehicle'])->name('autocomplete_driver_vehicle');
    Route::post('get_vehicle_info',[drivers::class,'get_vehicle_info'])->name('get_vehicle_info');
});


Route::get('driverlogin',[drivers::class,'driverlogin'])->name('driverlogin');
Route::post('driverdashboard',[driverdashboard::class,'driverlogged'])->name('driverlogged');
Route::get('driverdashboard',[driverdashboard::class,'index'])->name('index');
Route::get('driverlog',[driverdashboard::class,'driverlog'])->name('driverlog');


//vehicles routes
Route::group(['vehicles','middleware'=>['auth']],function(){
    Route::get('vehicles',[vehicles::class,'index'])->name('vehicles');
    Route::get('maintain_vehicles',[vehicles::class,'maintain_vehicle'])->name('maintain_vehicle');
    Route::post('maintain_vehicles',[vehicles::class,'save_vehicles'])->name('save_vehicles');
    Route::post('get_driver_id',[vehicles::class,'get_driver_id'])->name('get_driver_id');
    Route::post('get_driver_info',[vehicles::class,'get_driver_info'])->name('get_driver_info');

     Route::get('autocomplete_driver',[vehicles::class,'autocomplete_driver']);
});

//customer routes
Route::group(['customers','middleware'=>['auth']],function(){
    Route::get('customers',[customers::class,'index'])->name('customers');
    Route::get('maintain_customers',[customers::class,'maintain_customers'])->name('maintain_customers');
    Route::post('maintain_customers',[customers::class,'save_customers'])->name('save_customers');
});

//setting routes
Route::group(['settings','middleware'=>['auth']],function(){
    Route::get('settings',[settings::class,'index'])->name('settings');
    Route::post('save_settings',[settings::class,'save_settings'])->name('save_settings');

    //fixed routes
    Route::get('fixedroutes',[settings::class,'fixedroutes'])->name('fixedroutes');
    Route::get('addroutes',[settings::class,'addroutes'])->name('addroutes');
    Route::post('save_fixed_routes',[settings::class,'save_fixed_routes'])->name('save_fixed_routes');
});