<?php

use App\Http\Controllers\AUKController;
use App\Http\Controllers\DocumentController;
use App\Http\Controllers\MMCController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
use App\Http\Controllers\ProjectController;
use App\Http\Controllers\SelectProjectController;

/*
|--------------------------------------------------------------------------
| 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');


// Users
Route::prefix('admin')->middleware(['admin'])->group(function () {
    Route::resource('/users', UserController::class);
});

// Projects
Route::resource('/projects', ProjectController::class)->middleware(['auth']);
Route::post('/project/{project}/select',SelectProjectController::class)->middleware(['auth'])->name('project.select');

Route::resource('/mmc', MMCController::class)->middleware(['auth'])->only(['index','create']);
Route::get('/mmc/scan', [MMCController::class, 'scan'])->middleware(['auth'])->name('mmc.scan');
Route::resource('/documents', DocumentController::class)->except('show')->middleware(['auth']);
Route::resource('/auks', AUKController::class)->except('show')->middleware(['auth']);
Route::get('/auks/scan', [AUKController::class, 'scan'])->middleware(['auth'])->name('auks.scan');
Route::post('/auks/load', [AUKController::class, 'load'])->middleware(['auth'])->name('auks.load');

require __DIR__ . '/auth.php';
