<?php
use \App\Notifications\sms;
use Illuminate\Support\Facades\Storage;
/*
|--------------------------------------------------------------------------
| 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();
Route::get('logout', 'Auth\LoginController@logout')->name('logout');



/** Public Route */
Route::get('/', 'PublicController@index');
Route::get('/news', 'NewsController@index');
Route::get('/news/{id}', 'NewsController@show');
Route::get('/activity', 'ComplementaryActivityController@index');
Route::get('/activity/{id}', 'ComplementaryActivityController@show');
Route::get('/picture/{id}', 'PictureController@show');
Route::get('/pictures', 'PictureController@index');

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']);

        /** Schedule */
        Route::get('/admin/schedule/pdf/event/{id}','ScheduleController@printtopdf');
        Route::get('/admin/schedule/add/{date}','ScheduleController@create');
        Route::get('/admin/schedule/edit/{id}','EventController@edit');
        Route::post('/admin/schedule/event/add','EventController@Store');
        Route::post('/admin/schedule/event/edit/{id}','EventController@update');


        /** 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/{id}' , '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/schedule' , 'ScheduleController@index');
        Route::post('/admin/config/schedule/edit' , 'ScheduleController@update');
        Route::get('/admin/config/activity' , 'ComplementaryActivityController@index');
        Route::get('/admin/config/activity/add' , 'ComplementaryActivityController@create');
        Route::post('/admin/config/activity/add' , 'ComplementaryActivityController@store');
        Route::get('/admin/config/activity/edit/{id}' , 'ComplementaryActivityController@edit');
        Route::post('/admin/config/activity/edit/{id}' , 'ComplementaryActivityController@update');
        Route::post('/admin/config/general/edit','ConfigController@update');
        Route::get('/admin/config/' , 'ConfigController@index');
        Route::get('/admin/config/customisation','ConfigController@customisation');
        Route::post('/admin/config/customisation','ConfigController@customisationUpdate');

        /** Public page */
        Route::get('/admin/public/edit/{config}', 'PublicController@edit');
        Route::post('/admin/public/edit/{config}', 'PublicController@update');

        /** Picture */
        Route::get('/admin/picture','PictureController@indexAdmin');
        Route::get('/admin/picture/add','PictureController@create');
        Route::post('/admin/picture/add','PictureController@store');
        Route::get('/admin/picture/edit/{id}','PictureController@edit');
        Route::post('/admin/picture/edit/{id}','PictureController@update');

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

        /** Booking */
        Route::get('/admin/booking/{type}/{id}',function() {
            return 'A faire';
        });

        /** 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/password' , 'UserController@UserPassword');
        Route::get('/admin/profil/adress' , 'UserController@UserAdress');
        Route::post('/admin/profil/edit/adress' , 'UserController@editUserAdress');
        Route::post('/admin/profil/edit/password' , 'UserController@editUserPassword');
        Route::get('/admin/profil/edit/avatar/{id}' , 'UserController@editUserAvatar');
        Route::get('/admin/profil/{id?}' , 'UserController@showUserProfil');

        /** Files */
        Route::get('/admin/files','FilesController@index');
        Route::get('/admin/guide','FilesController@guide');
});

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');
        Route::get('/ecc/list','ECCController@list');
        Route::get('/ecc/files','ECCController@files');
        Route::get('/ecc/settings','ECCController@settings');
        Route::get('/ecc/settings/password' , 'ECCController@UserPassword');
        Route::post('/ecc/settings/edit/password' , 'UserController@editUserPassword');
        Route::get('/ecc/settings/avatar', 'ECCController@UserAvatar');
        Route::get('/ecc/settings/edit/avatar/{id}' , 'UserController@editUserAvatar');
        Route::get('/ecc/settings/adress', 'ECCController@UserAdress');
        Route::post('/ecc/settings/edit/adress', 'UserController@editUserAdress');


});


