<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\User\UserController;
use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\BoltWithNutsMsMController;
use App\Http\Controllers\BoltWithNutsInchController;
use App\Http\Controllers\BoltsMsMController;
use App\Http\Controllers\FlangeNBController;
use App\Http\Controllers\MainBodyController;
use App\Http\Controllers\PartController;
use App\Http\Controllers\MocController;
use App\Http\Controllers\PipeWgtMocController;

use App\Http\Controllers\AnfController;

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

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

Route::get('/user-profile-page', function () {
    return view('auth/profile');
});

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

Route::middleware(['auth'])->group(function () {
    Route::group(['middleware' => ['role:admin']], function () {
        Route::get('/admin/dashboard', [AdminController::class, 'adminDashboard'])->name('admin/dashboard');
        Route::get('/admin/profile', [AdminController::class, 'profile'])->name('admin/profile');
        Route::post('/admin/profile/update]', [AdminController::class, 'profileupdate'])->name('admin/profile/update');
        // bolt with nuts-ms-m
        Route::get('/admin/boltwithnuts/ms', [BoltWithNutsMsMController::class, 'index'])->name('admin/boltwithnuts/ms');
        Route::get('/admin/boltwithnuts/ms/create', [BoltWithNutsMsMController::class, 'create'])->name('admin/boltwithnuts/ms/create');
        Route::post('/admin/boltwithnuts/ms/store', [BoltWithNutsMsMController::class, 'store'])->name('admin/boltwithnuts/ms/store');
        Route::get('/admin/boltwithnuts/ms/show/{id}', [BoltWithNutsMsMController::class, 'show'])->name('admin/boltwithnuts/ms/show');
        Route::get('/admin/boltwithnuts/ms/edit/{id}', [BoltWithNutsMsMController::class, 'edit'])->name('admin/boltwithnuts/ms/edit');
        Route::post('/admin/boltwithnuts/ms/update', [BoltWithNutsMsMController::class, 'update'])->name('admin/boltwithnuts/ms/update');
        Route::post('/admin/boltwithnuts/ms/delete', [BoltWithNutsMsMController::class, 'destroy'])->name('admin/boltwithnuts/ms/delete');
        // bolt with nuts-inch
        Route::get('/admin/boltwithnuts/inch', [BoltWithNutsInchController::class, 'index'])->name('admin/boltwithnuts/inch');
        Route::get('/admin/boltwithnuts/inch/create', [BoltWithNutsInchController::class, 'create'])->name('admin/boltwithnuts/inch/create');
        Route::post('/admin/boltwithnuts/inch/store', [BoltWithNutsInchController::class, 'store'])->name('admin/boltwithnuts/inch/store');
        Route::get('/admin/boltwithnuts/inch/show/{id?}', [BoltWithNutsInchController::class, 'show'])->name('admin/boltwithnuts/inch/show');
        Route::get('/admin/boltwithnuts/inch/edit/{id?}', [BoltWithNutsInchController::class, 'edit'])->name('admin/boltwithnuts/inch/edit');
        Route::post('/admin/boltwithnuts/inch/update', [BoltWithNutsInchController::class, 'update'])->name('admin/boltwithnuts/inch/update');
        Route::post('/admin/boltwithnuts/inch/delete', [BoltWithNutsInchController::class, 'destroy'])->name('admin/boltwithnuts/inch/delete');
        // bolts-MS-M
        Route::get('/admin/bolts/msm', [BoltsMsMController::class, 'index'])->name('admin/bolts/msm');
        Route::get('/admin/bolts/msm/create', [BoltsMsMController::class, 'create'])->name('admin/bolts/msm/create');
        Route::post('/admin/bolts/msm/store', [BoltsMsMController::class, 'store'])->name('admin/bolts/msm/store');
        Route::get('/admin/bolts/msm/show/{id?}', [BoltsMsMController::class, 'show'])->name('admin/bolts/msm/show');
        Route::get('/admin/bolts/msm/edit/{id?}', [BoltsMsMController::class, 'edit'])->name('admin/bolts/msm/edit');
        Route::post('/admin/bolts/msm/update', [BoltsMsMController::class, 'update'])->name('admin/bolts/msm/update');
        Route::post('/admin/bolts/msm/delete', [BoltsMsMController::class, 'destroy'])->name('admin/bolts/msm/delete');
        // part body
        Route::get('/admin/part', [PartController::class, 'index'])->name('admin/part');
        Route::get('/admin/part/create', [PartController::class, 'create'])->name('admin/part/create');
        Route::post('/admin/part/store', [PartController::class, 'store'])->name('admin/part/store');
        Route::get('/admin/part/show/{id?}', [PartController::class, 'show'])->name('admin/part/show');
        Route::get('/admin/part/edit/{id?}', [PartController::class, 'edit'])->name('admin/part/edit');
        Route::post('/admin/part/update/{id?}', [PartController::class, 'update'])->name('admin/part/update');
        Route::post('/admin/part/delete', [PartController::class, 'destroy'])->name('admin/part/delete');
        // MOC
        Route::get('/admin/moc', [MocController::class, 'index'])->name('admin/moc');
        Route::get('/admin/moc/create', [MocController::class, 'create'])->name('admin/moc/create');
        Route::post('/admin/moc/store', [MocController::class, 'store'])->name('admin/moc/store');
        Route::get('/admin/moc/show/{id?}', [MocController::class, 'show'])->name('admin/moc/show');
        Route::get('/admin/moc/edit/{id?}', [MocController::class, 'edit'])->name('admin/moc/edit');
        Route::post('/admin/moc/update/{id?}', [MocController::class, 'update'])->name('admin/moc/update');
        Route::post('/admin/moc/delete', [MocController::class, 'destroy'])->name('admin/moc/delete');
        // main body
        Route::get('/admin/mainbody', [MainBodyController::class, 'index'])->name('admin/mainbody');
        Route::get('/admin/mainbody/create', [MainBodyController::class, 'create'])->name('admin/mainbody/create');
        Route::post('/getmocvalue', [MainBodyController::class, 'mocValueGet'])->name('getmocvalue');
        // Pipe wgt moc
        Route::get('/admin/pipewgtmoc', [PipeWgtMocController::class, 'index'])->name('admin/pipewgtmoc');
        Route::get('/admin/pipewgtmoc/create', [PipeWgtMocController::class, 'create'])->name('admin/pipewgtmoc/create');
        Route::post('/admin/pipewgtmoc/store', [PipeWgtMocController::class, 'store'])->name('admin/pipewgtmoc/store');
        Route::get('/admin/pipewgtmoc/show/{id?}', [PipeWgtMocController::class, 'show'])->name('admin/pipewgtmoc/show');
        Route::get('/admin/pipewgtmoc/edit/{id?}', [PipeWgtMocController::class, 'edit'])->name('admin/pipewgtmoc/edit');
        Route::post('/admin/pipewgtmoc/update/{id?}', [PipeWgtMocController::class, 'update'])->name('admin/pipewgtmoc/update');
        Route::post('/admin/pipewgtmoc/delete', [PipeWgtMocController::class, 'destroy'])->name('admin/pipewgtmoc/delete');
        // get search id
        Route::post('/getsch', [PipeWgtMocController::class, 'isCheckschedule'])->name('getsch');
        Route::post('/getflange', [PipeWgtMocController::class, 'isCheckFlange'])->name('getflange');
        Route::post('/getflange/weight', [PipeWgtMocController::class, 'isCheckFlangeWeight'])->name('getflange/weight');
        Route::post('/getflange/fastner', [PipeWgtMocController::class, 'isCheckFlangeFastner'])->name('getflange/fastner');
        // flange wgt moc     
        Route::get('/admin/flange/nozzle', [FlangeNBController::class, 'index'])->name('admin/flange/nozzle');
        Route::get('/admin/flange/nozzle/create', [FlangeNBController::class, 'create'])->name('admin/flange/nozzle/create');
        Route::post('/admin/flange/nozzle/store', [FlangeNBController::class, 'store'])->name('admin/flange/nozzle/store');
        Route::get('/admin/flange/nozzle/show/{id?}', [FlangeNBController::class, 'show'])->name('admin/flange/nozzle/show');
        Route::get('/admin/flange/nozzle/edit/{id?}', [FlangeNBController::class, 'edit'])->name('admin/flange/nozzle/edit');
        Route::post('/admin/flange/nozzle/update/{id?}', [FlangeNBController::class, 'update'])->name('admin/flange/nozzle/update');
        Route::post('/admin/flange/nozzle/delete', [FlangeNBController::class, 'destroy'])->name('admin/flange/nozzle/delete');

    });

    Route::get('/anf/{category}/{size}', [AnfController::class, 'show'])
    ->where('category', '.*') // spaces/slashes allow karega
    ->name('anf.show');

    Route::group(['middleware' => ['role:user']], function () {
        Route::get('/user/dashboard', [UserController::class, 'userDashboard'])->name('user/dashboard');
        Route::get('/user/profile', [UserController::class, 'profile'])->name('user/profile');
        Route::post('/user/profile/update', [UserController::class, 'profileUpdate'])->name('user/profile/update');
    });
});
Auth::routes();
