<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\CompanyController;
use App\Http\Controllers\companyBranchController;
use App\Http\Controllers\itemCategoriesController;
use App\Http\Controllers\itemsController;
use App\Http\Controllers\routes_controller;
use App\Http\Controllers\customersController;
use App\Http\Controllers\employeeController;
use App\Http\Controllers\supplierController;
use App\Http\Controllers\variableSettings;
use App\Http\Controllers\purchaseController;
use App\Http\Controllers\bankController;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

/*
|--------------------------------------------------------------------------
| 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 redirect()->route('login');
});

Route::get('/NewDashboard', function () {
    return Inertia::render('NewDash'); 
})->middleware(['auth', 'verified'])->name('NewDash');

//Compnay data routes
Route::post('/company/store', [CompanyController::class, 'store'])->middleware(['auth', 'verified'])->name('company.store');
Route::get('/company/index', [CompanyController::class, 'index'])->name('company.index');
Route::put('/company/update/{id}', [CompanyController::class, 'update'])->middleware(['auth', 'verified'])->name('company.update');

//Company branch data routes
Route::post('/companyBranch/store', [companyBranchController::class, 'store'])->middleware(['auth', 'verified'])->name('companyBranch.store');
Route::get('/companyBranch/index', [companyBranchController::class, 'index'])->name('companyBranch.index');
Route::put('/companyBranch/update/{id}', [companyBranchController::class, 'update'])->middleware(['auth', 'verified'])->name('companyBranch.update');
Route::get('/companyBranch/show/{id}', [CompanyBranchController::class, 'show'])->name('companyBranch.show');

//Item categories data routes
Route::post('/itemCategories/store', [itemCategoriesController::class, 'store'])->middleware(['auth', 'verified'])->name('itemCategories.store');
Route::get('/itemCategories/index', [itemCategoriesController::class, 'index'])->middleware(['auth', 'verified'])->name('itemCategories.index');
Route::put('/itemCategories/update/{id}', [itemCategoriesController::class, 'update'])->middleware(['auth', 'verified'])->name('itemCategories.update');

//Items data routes
Route::get('/items/index', [itemsController::class,'index'])->middleware(['auth', 'verified'])->name('items.index');
Route::post('/items/store', [itemsController::class, 'store'])->middleware(['auth', 'verified'])->name('items.store');
Route::put('/items/update/{id}', [itemsController::class, 'update'])->middleware(['auth', 'verified'])->name('items.update');
Route::post('/items/searchbox', [itemsController::class, 'searchbox'])->middleware(['auth', 'verified'])->name('items.searchbox');

//Routes data routes
Route::get('/routes/index', [routes_controller::class,'index'])->middleware(['auth', 'verified'])->name('routes.index');
Route::post('/routes/store', [routes_controller::class, 'store'])->middleware(['auth', 'verified'])->name('routes.store');
Route::put('/routes/update/{id}', [routes_controller::class, 'update'])->middleware(['auth', 'verified'])->name('routes.update');

//Customers data routes
Route::post('/customers/store', [customersController::class, 'store'])->middleware(['auth', 'verified'])->name('customers.store');
Route::get('/customers/index', [customersController::class,'index'])->middleware(['auth', 'verified'])->name('customers.index');
Route::put('/customers/update/{id}', [customersController::class, 'update'])->middleware(['auth', 'verified'])->name('customers.update');

//Employee data routes
Route::post('/employee/store', [employeeController::class, 'store'])->middleware(['auth', 'verified'])->name('employee.store');
Route::get('/employeePosition/index', [employeeController::class,'empoloyeesPositionIndex'])->middleware(['auth', 'verified'])->name('employee.empoloyeesPositionIndex');
Route::get('/employee/index', [employeeController::class,'index'])->middleware(['auth', 'verified'])->name('employee.index');
Route::put('/employee/update/{id}', [employeeController::class, 'update'])->middleware(['auth', 'verified'])->name('employee.update');

//Suppliers data routes
Route::post('/suppliers/store', [supplierController::class,'store'])->middleware(['auth', 'verified'])->name('suppliers.store');
Route::get('/suppliers/index', [supplierController::class,'index'])->middleware(['auth', 'verified'])->name('suppliers.index');
Route::put('/suppliers/update/{id}', [supplierController::class,'update'])->middleware(['auth', 'verified'])->name('suppliers.update');

//Variable settings data routes
Route::post('/variableSettings/store', [variableSettings::class,'store'])->middleware(['auth', 'verified'])->name('variableSettings.store');
Route::get('/variableSettings/index', [variableSettings::class,'index'])->middleware(['auth', 'verified'])->name('variableSettings.index');
Route::put('/variableSettings/update/{id}', [variableSettings::class,'update'])->middleware(['auth', 'verified'])->name('variableSettings.update');

//Purchese data routes
Route::get('/purchase/index', [purchaseController::class,'index'])->middleware(['auth', 'verified'])->name('purchase.index');
Route::post('/purchase/store', [purchaseController::class,'store'])->middleware(['auth', 'verified'])->name('purchase.store');

//Banks data routes
Route::post('/bank/store', [bankController::class,'store'])->middleware(['auth', 'verified'])->name('bank.store');
Route::get('/bank/index', [bankController::class,'index'])->middleware(['auth', 'verified'])->name('bank.index');
Route::put('/bank/update/{id}', [bankController::class,'update'])->middleware(['auth', 'verified'])->name('bank.update');

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

Route::middleware('auth')->group(function () {
    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__.'/auth.php';
