<?php

use App\Http\Controllers\HomeController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\CustomerController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\WarhouseController;
use App\Http\Controllers\ShipperController;
use App\Http\Controllers\ChannelController;
use Illuminate\Support\Facades\Auth;
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('/', function () {
    return redirect()->route('login');
});

Auth::routes(['register' => false]);

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

// Profile Routes
Route::prefix('profile')->name('profile.')->middleware('auth')->group(function(){
    Route::get('/', [HomeController::class, 'getProfile'])->name('detail');
    Route::post('/update', [HomeController::class, 'updateProfile'])->name('update');
    Route::post('/change-password', [HomeController::class, 'changePassword'])->name('change-password');
});

// Roles
Route::resource('roles', App\Http\Controllers\RolesController::class);

// Permissions
Route::resource('permissions', App\Http\Controllers\PermissionsController::class);

// Users 
Route::middleware('auth')->prefix('users')->name('users.')->group(function(){
    Route::get('/', [UserController::class, 'index'])->name('index');
    Route::get('/create', [UserController::class, 'create'])->name('create');
    Route::post('/store', [UserController::class, 'store'])->name('store');
    Route::get('/edit/{user}', [UserController::class, 'edit'])->name('edit');
    Route::put('/update/{user}', [UserController::class, 'update'])->name('update');
    Route::delete('/delete/{user}', [UserController::class, 'delete'])->name('destroy');
    Route::get('/update/status/{user_id}/{status}', [UserController::class, 'updateStatus'])->name('status');

    
    Route::get('/import-users', [UserController::class, 'importUsers'])->name('import');
    Route::post('/upload-users', [UserController::class, 'uploadUsers'])->name('upload');

    Route::get('export/', [UserController::class, 'export'])->name('export');

});

// Products

Route::middleware('auth')->prefix('productlist')->name('productlist.')->group(function(){
    Route::get('/', [ProductController::class, 'index'])->name('index');
    Route::get('/createinventory', [ProductController::class, 'createinventory'])->name('createinventory');
    Route::post('/storeinventory', [ProductController::class, 'storeinventory'])->name('storeinventory');
    Route::get('/inventoryedit/{products}', [ProductController::class, 'inventoryedit'])->name('inventoryedit');
    Route::put('/updateinventory/{id}', [ProductController::class, 'updateinventory'])->name('updateinventory');
    Route::delete('/inventorydestroy/{id}', [ProductController::class, 'inventorydestroy'])->name('inventorydestroy');
    //Route::get('/createcategoryforinventory', [ProductController::class, 'createcategoryforinventory'])->name('createcategoryforinventory');
    //   Route::resource('products', ProductController::class); 
   // Route::get('posts', [PostController::class, 'index']);

});

///customer
Route::middleware('auth')->prefix('customerlist')->name('customerlist.')->group(function(){
    Route::get('/', [CustomerController::class, 'index'])->name('index');
    Route::get('/updateCustomerStatus/status/{id}/{status}', [CustomerController::class, 'updateCustomerStatus'])->name('updateCustomerStatus');
     Route::get('/createcustomer', [CustomerController::class, 'createcustomer'])->name('createcustomer');
  Route::post('/storecustomer', [CustomerController::class, 'storecustomer'])->name('storecustomer');
    Route::get('/Customeredit/{id}', [CustomerController::class, 'Customeredit'])->name('Customeredit');
    Route::put('/updateCustomerDetails/{id}', [CustomerController::class, 'updateCustomerDetails'])->name('updateCustomerDetails');
     Route::delete('/customerdestroy/{id}', [CustomerController::class, 'customerdestroy'])->name('customerdestroy');
   

});

//Category
Route::middleware('auth')->prefix('categorylist')->name('categorylist.')->group(function(){
    Route::get('/', [CategoryController::class, 'index'])->name('index');
     Route::get('/updatecategoryStatus/status/{id}/{status}', [CategoryController::class, 'updatecategoryStatus'])->name('updatecategoryStatus');
Route::get('/createcategory', [CategoryController::class, 'createcategory'])->name('createcategory');
  Route::post('/storecategory', [CategoryController::class, 'storecategory'])->name('storecategory');
     Route::get('/Categoryedit/{id}', [CategoryController::class, 'Categoryedit'])->name('Categoryedit');
   Route::put('/updatecategoryDetails/{id}', [CategoryController::class, 'updatecategoryDetails'])->name('updatecategoryDetails');
      Route::delete('/categorydestroy/{id}', [CategoryController::class, 'categorydestroy'])->name('categorydestroy');
   

});


//warehouses
Route::middleware('auth')->prefix('warehouselist')->name('warehouselist.')->group(function(){
    Route::get('/', [WarhouseController::class, 'index'])->name('index');
  Route::get('/updatewarehouseStatus/status/{id}/{status}', [WarhouseController::class, 'updatewarehouseStatus'])->name('updatewarehouseStatus');
 Route::get('/createwarehouse', [WarhouseController::class, 'createwarehouse'])->name('createwarehouse');
  Route::post('/storewarehouse', [WarhouseController::class, 'storewarehouse'])->name('storewarehouse');
     Route::get('/warehousedit/{id}', [WarhouseController::class, 'warehousedit'])->name('warehousedit');
    Route::put('/updatewarehouseDetails/{id}', [WarhouseController::class, 'updatewarehouseDetails'])->name('updatewarehouseDetails');
    Route::delete('/wharhousedestroy/{id}', [WarhouseController::class, 'wharhousedestroy'])->name('wharhousedestroy');
   

});

//SHipper
Route::middleware('auth')->prefix('shipperlist')->name('shipperlist.')->group(function(){
    Route::get('/', [ShipperController::class, 'index'])->name('index');
  Route::get('/updateshipperStatus/status/{id}/{status}', [ShipperController::class, 'updateshipperStatus'])->name('updateshipperStatus');
 Route::get('/createshipper', [ShipperController::class, 'createshipper'])->name('createshipper');
  Route::post('/storeshipper', [ShipperController::class, 'storeshipper'])->name('storeshipper');
     Route::get('/shipperdit/{id}', [ShipperController::class, 'shipperdit'])->name('shipperdit');
    Route::put('/updateshipperDetails/{id}', [ShipperController::class, 'updateshipperDetails'])->name('updateshipperDetails');
    Route::delete('/shipperdestroy/{id}', [ShipperController::class, 'shipperdestroy'])->name('shipperdestroy');
   

});

//channels
Route::middleware('auth')->prefix('channellist')->name('channellist.')->group(function(){
    Route::get('/', [ChannelController::class, 'index'])->name('index');
  Route::get('/updatechannelStatus/status/{id}/{status}', [ChannelController::class, 'updatechannelStatus'])->name('updatechannelStatus');
  Route::get('/createChannels', [ChannelController::class, 'createChannels'])->name('createChannels');
   Route::post('/storechannels', [ChannelController::class, 'storechannels'])->name('storechannels');
     Route::get('/channeldit/{id}', [ChannelController::class, 'channeldit'])->name('channeldit');
    Route::put('/updatechannelsDetails/{id}', [ChannelController::class, 'updatechannelsDetails'])->name('updatechannelsDetails');
   Route::delete('/channeldestroy/{id}', [ChannelController::class, 'channeldestroy'])->name('channeldestroy');
   

});