<?php
use \App\Notifications\sms;
/*
|--------------------------------------------------------------------------
| 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!
|
*/

/* Basic Auth Route */
Auth::routes();

/* Index Route */
Route::get('/', function () {
    return view('default');
});

Route::middleware(['auth','admin'])->group(function () {

    /* Espace Administration Route */

        /** Dashboard & General */
        Route::get('/admin', 'AdminController@index')->name('admin');
        Route::get('/admin/update', 'AdminController@update');

        /** Calendar */
        Route::get('/admin/calendar', 'CalendarController@index');
        Route::get('/admin/calendar/add/{date}', ['uses' =>'CalendarController@add']);
        Route::get('/admin/calendar/edit/{id}', ['uses' =>'CalendarController@edit']);
        Route::post('/admin/calendar/add', 'CalendarController@store');
        Route::patch('/admin/calendar/edit/{id}', ['uses' =>'CalendarController@patch']);

        /** Statistique */
        Route::get('/admin/stats/log' , 'LogController@index');

        /** Message */
        Route::get('/admin/message' , 'MessageController@index');
        Route::get('/admin/message/add' , 'MessageController@create');
        Route::post('/admin/message/add' , 'MessageController@store');
        Route::get('/admin/message/{id}', ['uses' =>'MessageController@show']);

        /** User */
        Route::get('/admin/user' , 'UserController@index');
        Route::get('/admin/user/add' , 'UserController@create');
        Route::post('/admin/user/add' , 'UserController@store');
        Route::get('/admin/user/edit/{id}' , 'UserController@edit');
        Route::post('/admin/user/edit' , 'UserController@update');

        /** Config */
        Route::get('/admin/config/job' , 'JobController@index');
        Route::get('/admin/config/job/add' , 'JobController@create');
        Route::post('/admin/config/job/add' , 'JobController@store');
        Route::get('/admin/config/job/edit/{id}' , 'JobController@edit');
        Route::get('/admin/config' , 'ConfigController@index');


        /** Inventory */
        Route::get('/admin/inventory' , 'InventoryController@index');
        Route::get('/admin/inventory/booking' , 'InventoryController@booking');
        Route::get('/admin/inventory/{id}/{periode}/{niveau}' , 'InventoryController@show');
        Route::post('/admin/inventory/add/{id}/{periode}/{niveau}' , 'InventoryController@store');
        Route::post('/admin/inventory/remove/{id}/{periode}/{niveau}' , 'InventoryController@destroy');

        /** Item */
        Route::get('/admin/item/add' , 'ItemController@create');
        Route::get('/admin/item/edit/{id}' , 'ItemController@edit');
        Route::post('/admin/item/add' , 'ItemController@store');
        Route::post('/admin/item/edit/{id}' , 'ItemController@update');
        /** Local */
        Route::get('/admin/config/local' , 'LocalController@index');

        /** Notification */
        Route::get('/admin/notication/mark','UserController@notificationmarkALL');
        Route::post('/admin/notication/mark/{id}','UserController@notificationmark');        
        Route::get('/ecc/notication/mark','UserController@notificationmarkALL');
        Route::post('/ecc/notication/mark/{id}','UserController@notificationmarkECC');

        /** Profil */
        Route::get('/admin/profil/avatar' , 'UserController@UserAvatar');
        Route::get('/admin/profil/edit/avatar/{id}' , 'UserController@editUserAvatar');
        Route::get('/admin/profil/{id?}' , 'UserController@showUserProfil');

});

Route::middleware(['auth','staff'])->group(function () {

    /** Espace Cadet cadre */
        Route::get('/ecc','ECCController@index');
        Route::get('/ecc/messages','ECCController@messages');
        Route::get('/ecc/messages/{page}','ECCController@messages');
        Route::get('/ecc/message/{id}','ECCController@message');
        Route::get('/ecc/guide','ECCController@guide');
        Route::get('/ecc/update','ECCController@update');
        Route::get('/ecc/calendar','ECCController@calendar');
        Route::get('/ecc/calendar/{date}','ECCController@calendar_date');
        Route::get('/ecc/inventory/{id}/{niveau}/{periode}' , 'ECCController@booking');
        Route::post('/ecc/inventory/add/{id}/{periode}/{niveau}' , 'ECCController@booking_add');
        Route::post('/ecc/inventory/remove/{id}/{periode}/{niveau}' , 'ECCController@booking_remove');
});
/* Other Route */
Route::get('/test', function () {

    dd(getStatus());

});

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


