<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\AnneeController;
use App\Http\Controllers\Api\PoleController;
use App\Http\Controllers\Api\AxeController;
use App\Http\Controllers\Api\ChargesPotentielleProfController;

use App\Http\Controllers\Api\RapportPdfController;

use App\Http\Controllers\Api\CommuneController;
use App\Http\Controllers\Api\CycleController;
use App\Http\Controllers\Api\DisciplineController;
use App\Http\Controllers\Api\EtabAxeController;

use App\Http\Controllers\Api\EtabProfController;
use App\Http\Controllers\Api\HoraireController;
use App\Http\Controllers\Api\ProfesseurController;
use App\Http\Controllers\Api\InfrastructureController;

use App\Http\Controllers\Api\RapportController;
use App\Http\Controllers\Api\NiveauController;
use App\Http\Controllers\Api\MoughataaController;
use App\Http\Controllers\Api\RegionController;
use App\Http\Controllers\Api\InspecteurController;
use App\Http\Controllers\Api\RapportInspectionController;
use App\Http\Controllers\Api\EtablissementController;

use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\DashboardController;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');

Route::post('/login', [AuthController::class, 'login'])->name('login');
Route::post('/register', [AuthController::class, 'register'])->name('register');

Route::prefix('v1')->middleware('auth:sanctum')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index']);
    
    Route::get(
        '/rapport/{id}/pdf',
        [RapportPdfController::class, 'generate']
    );
    Route::get('/regions-inspecteur/{pole}', [RapportInspectionController::class, 'regionsInspecteur']);

    Route::get('/moughataas/{region}', [RapportInspectionController::class, 'moughataas']);

    Route::get('/communes/{moughataa}', [RapportInspectionController::class, 'communes']);

    Route::get('/etablissements/{commune}', [RapportInspectionController::class, 'etablissements']);

    Route::get('/professeurs/{etablissement}', [RapportInspectionController::class, 'professeurs']);

    Route::post('/rapports', [RapportInspectionController::class, 'store']);
  
    Route::apiResource('etablissements', EtablissementController::class);

    Route::apiResource('axes', AxeController::class);
    Route::apiResource('rapports', RapportController::class);
    Route::apiResource('moughataas', MoughataaController::class);
    Route::apiResource('regions', RegionController::class);

   
    Route::apiResource('professeurs', ProfesseurController::class);

    Route::apiResource('niveaus', NiveauController::class);

    Route::apiResource('charges_potentielle_profs', ChargesPotentielleProfController::class);
    Route::apiResource('communes', CommuneController::class);
    Route::apiResource('cycles', CycleController::class);

    Route::apiResource('etab_axes', EtabAxeController::class);
    Route::apiResource('etab_profs', EtabProfController::class);
    Route::apiResource('horaires', HoraireController::class);
    Route::apiResource('infrastructures', InfrastructureController::class);

Route::apiResource('disciplines', DisciplineController::class);
Route::apiResource('poles', PoleController::class);
Route::apiResource('inspecteurs', InspecteurController::class);
Route::apiResource('annees', AnneeController::class);

});
