<?php

use App\Http\Controllers\AdminAccesController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\HashController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\SignatureController;
use App\Http\Controllers\SuperController;
use App\Http\Controllers\Utilisateur_PolicierController;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\ErrorController;
use App\Http\Controllers\PdfController;
/*
|--------------------------------------------------------------------------
| 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('user.index');
   // return view('welcome');
})->name('auth');

Route::get("/contact",[ContactController::class,'showForm'])->name('show');
Route::post('/contact',[ContactController::class,'sendEmail'])->name('contact.send');

Auth::routes();
// User Route
Route::middleware(['auth','user-role:user'])->group(function()
{
    Route::get("/home",[HomeController::class,'userHome'])->name('home');
    Route::put("/update_police/{id}",[HomeController::class,'updatePolicier'])->name('update_police');
    Route::resource('/signature', SignatureController::class);
});


// Editor Route
Route::middleware(['auth','user-role:editor'])->group(function()
{
    Route::get("/editor/home",[HomeController::class,'editorHome'])->name('home.editor');
    Route::resource('/admins', SuperController::class);
    Route::resource('/compte', Utilisateur_PolicierController::class);
    Route::get("/search-policier",[Utilisateur_PolicierController::class,'search'])->name('search-policier');
    Route::resource('/compte_admin', AdminAccesController::class);
    Route::get("/search",[SuperController::class,'search'])->name('search');
    Route::resource('/pdf', PdfController::class);

});

// Admin Route
Route::middleware(['auth','user-role:admin'])->group(function()
{
    Route::get("/admin/home",[HomeController::class,'adminHome'])->name('home.admin');
    Route::resource('/admin', AdminController::class);
    Route::resource('/pdfs', PdfController::class);
});

Route::resource('/Error', ErrorController::class);
