<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
//Route::get('article/article_data', 'API\v1\ArticleController@article_data');
Route::post('test', 'API\v1\TestController@test');

Route::post('tenant/load', 'API\v1\TenantController@load_tenant');

// Route to provide key for departement
Route::post('api_key/auth','API\v1\DepartementController@authenticate');

//Route to provide information on user with his token
Route::post('user/token/auth','API\v1\UserController@showUser');


Route::group(['middleware' => ['verify_api_key']], function () {

//  //offres
//     Route::get('offres','API\v1\OffresController@index');
//     Route::get('offres/{offres_id}','API\v1\OffresController@get_offre');
//     Route::get('offres/show/{offres_id}','API\v1\OffresController@show_offre');
//     // Route::get('t_offres','API\v1\OffresController@admin_t_offres');
//     Route::get('offre_active_desabled/{status}/{offre_id}','API\v1\OffresController@action_act_des');
//     //edit
//     Route::get('offre_get_datas_edit/{offre_id}','API\v1\OffresController@offre_get_datas_edit');
//     Route::post('offre/edit','API\v1\OffresController@edit_offre');

    //store demande

    Route::post('offre/demande/store','API\v1\OffresController@store');
    Route::post('offre/store','API\v1\OffresController@store_offre');

    //demande

    //recuperation de toutes les demandes
    Route::get('demande','API\v1\OffresController@demande_liste');
    Route::get('postuler/offres/{offre}/theme/{theme}','API\v1\OffresController@demande_offre_theme');

    //recuperation d'une seule demande en donction de l'id
    Route::get('demande/{demande_id}','API\v1\OffresController@demande_show');
    Route::delete('admin/delete/{offre}', 'API\v1\OffresController@destroy');

    //theme
    //store therm
    Route::post('theme/store','API\v1\OffresController@theme_store');

    //decision
    Route::post('demande/decision/store','API\v1\OffresController@demande_decision');





    Route::group(['middleware' => ['switch_db']], function () {

        Route::post('user/auth', 'API\v1\UserController@authenticate');
        Route::post('user/logout/{matricule}', 'API\v1\UserController@logout');
        Route::apiResource('departement', 'API\v1\DepartementController');

        Route::get('aptitude/aptitude_filiere','API\v1\AptitudeController@aptitudeFiliere');
        Route::apiResource('aptitude','API\v1\AptitudeController'); //
        Route::get('articles/{statut?}', 'API\v1\ArticleController@article_filtered')->where('statut', '[A-Za-z]+');
        Route::get('article/{article}', 'API\v1\ArticleController@show');
        Route::apiResource('commentaire', 'API\v1\CommentaireController');
        Route::apiResource('competence','API\v1\CompetenceController');
        Route::apiResource('contenant', 'API\v1\ContenantController');
        Route::apiResource('contentimage', 'API\v1\ContentimageController');
        Route::apiResource('contentvideo', 'API\v1\ContentvideoController');
        Route::apiResource('contenttexte', 'API\v1\ContenttexteController');
        Route::apiResource('contenu', 'API\v1\ContenuController');
        // Routes for all pages
        Route::put('contenu/{contenu}/restore', 'API\v1\ContenuController@restore')->name('contenu.restore');
        //Routes for debouche and competence
        Route::apiResource('debouche','API\v1\DeboucheController');
        Route::post('filiere/attribute_aptitude','API\v1\FiliereController@attributeAptitudes');
        Route::apiResource('filiere','API\v1\FiliereController');

        Route::apiResource('page', 'API\v1\PageController');
        Route::get('pages_sites', 'API\v1\PageController@index_sites');

        //Route::get('page','API\v1\PageController@index');
       // Route::put('page/{page}/restore', 'API\v1\PageController@restore')->name('page.restore');
       Route::get('profils/{user_matricule}', 'API\v1\ProfileController@showProfil');

       Route::get('etudiants_theme', 'API\v1\ThemeController@etudiants_theme'); // à remettre à sa place
       Route::get('etudiants_sans_theme', 'API\v1\ThemeController@etudiants_sans_theme');// à remettre à sa place
       Route::get('themes/{theme}/liens', 'API\v1\ThemeController@liens_theme');// à remettre à sa place
       Route::get('departements/profs/{prof}/dashboard', 'API\v1\ThemeController@data_for_prof');// à remettre à sa place
       Route::get('departements/stats', 'API\v1\UserController@stats');// à remettre à sa place


       Route::post('attribution_theme/{theme}', 'API\v1\ThemeController@attribution_theme');

        //Routes for sujets
        Route::apiResource('sujet', 'API\v1\SujetController');
        Route::get('sujet/user/sujets', 'API\v1\SujetController@index_user');

        Route::get('alumni/{offset}/{perPage}','API\v1\UserController@alumni');



        //offres
            Route::get('offres','API\v1\OffresController@index');
            Route::get('offres/{offres_id}','API\v1\OffresController@get_offre');
            Route::get('offres/show/{offres_id}','API\v1\OffresController@show_offre');
            Route::get('t_offres','API\v1\OffresController@admin_t_offres');
            Route::get('offre_active_desabled/{status}/{offre_id}','API\v1\OffresController@action_act_des');
            //edit
            Route::get('offre_get_datas_edit/{offre_id}','API\v1\OffresController@offre_get_datas_edit');
            Route::post('offre/edit','API\v1\OffresController@edit_offre');

        Route::get('all_filiere_in_gest/{departement?}','API\v1\FiliereController@getAllFiliereForDepartementInGest');

		  Route::get('filieres/{filiere}/ues','API\v1\FiliereController@show_ues');
		  Route::get('filieres/{filiere}/ecues','API\v1\FiliereController@show_ecues');
    });





    //Routes for Filiere
   // Route::get('all_filiere/{departement}','API\v1\FiliereController@getAllFiliereForDepartement');
    // Route::get('all_filiere_in_gest/{departement?}','API\v1\FiliereController@getAllFiliereForDepartementInGest');


    //Routes for Aptitude

    //Routes for Domaine
    Route::apiResource('domaine','API\v1\DomaineController');




    //Route::apiResource('article', 'API\v1\ArticleController');





});

Route::group(['middleware' => ['switch_db']], function () {
    //Routes for articles

    Route::get('doc_utile', 'API\v1\DocUtileController@index');
    // Route::get('doc_utiles', 'API\v1\DocUtileController@index');
    Route::get('doc_utile/{doc}', 'API\v1\DocUtileController@show');
    Route::get('categorie-doc-utile', 'API\v1\CategorieDocController@index');

    Route::group(['middleware' => ['verify_user_token']], function () {


        Route::post('doc_utile', 'API\v1\DocUtileController@store');
        Route::post('categorie-doc-utile', 'API\v1\CategorieDocController@store');
        Route::put('doc_utile/{doc_utile}', 'API\v1\DocUtileController@update');
        Route::put('categorie-doc-utile/{categorie}', 'API\v1\CategorieDocController@update');
        Route::delete('doc_utile/{doc_utile}', 'API\v1\DocUtileController@destroy');
        Route::delete('categorie-doc-utile/{categorie}', 'API\v1\CategorieDocController@destroy');

        Route::apiResource('section', 'API\v1\SectionController');

        Route::apiResource('paragraphe', 'API\v1\ParagrapheController');

        Route::apiResource('attachement', 'API\v1\AttachementController');
        Route::get('article', 'API\v1\ArticleController@index');
        Route::get('article/en_attente/data', 'API\v1\ArticleController@article_data');
        Route::post('article', 'API\v1\ArticleController@store');
        //Route::get('article/{article}', 'API\v1\ArticleController@show');  //Pas besoin d'être connecter pour voir le contenu d'un article
        Route::put('article/{article}', 'API\v1\ArticleController@update');
        Route::delete('article/{article}', 'API\v1\ArticleController@destroy');

        //Routes for documents
        Route::apiResource('document', 'API\v1\DocumentController');
        //Route for documents utiles

        Route::apiResource('categorie', 'API\v1\CategorieController');
        Route::apiResource('image', 'API\v1\ImageController');

    //Route::apiResource('lien', 'API\v1\LienController');
    Route::post('lien','API\v1\LienController@store');
    Route::put('lien/multiple_update','API\v1\LienController@multiple_update');
    Route::delete('lien/multiple_destroy','API\v1\LienController@multiple_destroy');

    Route::get('profils', 'API\v1\ProfileController@showProfil');
    Route::put('profils/{profil}', 'API\v1\ProfileController@update');

    //get profil for CD
    Route::get('profils/departement/cd', 'API\v1\ProfileController@cdProfil');




    //Routes for themes
    Route::get('valider_theme/{theme}', 'API\v1\ThemeController@valider_theme')->middleware('verify_can_validate_theme');
    Route::get('choisir_theme/{theme}', 'API\v1\ThemeController@choisir_theme');
    //Route::get('attribution_theme/{theme}', 'API\v1\ThemeController@attribution_theme')->middleware('verify_can_validate_theme');
    Route::get('rejeter_choix/{theme}', 'API\v1\ThemeController@rejeter_choix')->middleware('verify_can_validate_theme');
    Route::delete('supprimer_choix/{theme}', 'API\v1\ThemeController@supprimer_choix')->middleware('verify_can_validate_theme');
    Route::get('soutenu/{theme}', 'API\v1\ThemeController@soutenu')->middleware('verify_can_validate_theme');

    Route::apiResource('theme', 'API\v1\ThemeController');
    Route::put('theme/{theme}/restore','API\v1\ThemeController@restore');
    Route::get('themes_filiere', 'API\v1\ThemeController@themes_filiere');
    Route::get('themes/{theme}/detail', 'API\v1\ThemeController@show_theme_detail');

    //Routes for user profile
    Route::apiResource('user', 'API\v1\UserController');
    Route::get('users_articles', 'API\v1\UserController@article_show'); // les article d un user

    });












   // Route::apiResource('profile', 'API\v1\ProfileController');

});
