<?php

/*
|--------------------------------------------------------------------------
| 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('auth.login');
});

Auth::routes([
  //'register' => false,
  'verify' => false
]);

Route::group([
], function() {
    Route::get('/home', 'HomeController@index')->name('home');
    Route::group([
      'prefix' => 'users'
    ], function() {
        Route::get('/', 'UserController@index')->middleware('rolecheck:5');
        Route::delete('delete/{id}', 'UserController@destroy')->middleware('superadmin');
        Route::match(['get', 'put'], 'update/{id}', 'UserController@update')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'supplier'
    ], function() {
      Route::get('/', 'SupplierController@index')->middleware('rolecheck:5');
      Route::delete('delete/{id}', 'SupplierController@destroy')->middleware('superadmin');
      Route::match(['get', 'put'], 'update/{id}', 'SupplierController@update')->middleware('rolecheck:5');
      Route::match(['get', 'put'], 'certificate/{id}', 'SupplierController@certificate')->middleware('rolecheck:5');
      Route::match(['get', 'put', 'post'], 'create/{id}', 'SupplierController@create')->middleware('rolecheck:5');
      Route::match(['get', 'put', 'post'], 'edit', 'SupplierController@edit');
    });
    Route::group([
      'prefix' => 'categories'
    ], function() {
        Route::get('/', 'CategoriesController@index')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'CategoriesController@destroy')->middleware('superadmin');
        Route::match(['get', 'put'], 'update/{id}', 'CategoriesController@update')->middleware('rolecheck:6');
        Route::match(['get', 'post'], 'create', 'CategoriesController@create')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'banks'
    ], function() {
        Route::get('/', 'BanksController@index')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'BanksController@destroy')->middleware('superadmin');
        Route::match(['get', 'put'], 'update/{id}', 'BanksController@update')->middleware('rolecheck:6');
        Route::match(['get', 'post'], 'create', 'BanksController@create')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'coupons'
    ], function() {
        Route::get('/', 'CouponController@index')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'CouponController@destroy')->middleware('superadmin');
        Route::match(['get', 'put'], 'update/{id}', 'CouponController@update')->middleware('rolecheck:6');
        Route::match(['get', 'post'], 'create', 'CouponController@create')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'parameters'
    ], function() {
        Route::get('/', 'IChambaParameterController@index')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'IChambaParameterController@destroy')->middleware('superadmin');
        Route::match(['get', 'put'], 'update/{id}', 'IChambaParameterController@update')->middleware('rolecheck:6');
        Route::match(['get', 'post'], 'create', 'IChambaParameterController@create')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'status'
    ], function() {
        Route::get('/', 'StatusController@index')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'StatusController@destroy')->middleware('superadmin');
        Route::match(['get', 'put'], 'update/{id}', 'StatusController@update')->middleware('rolecheck:6');
        Route::match(['get', 'post'], 'create', 'StatusController@create')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'payments'
    ], function() {
        Route::get('/', 'PaymentController@index')->middleware('rolecheck:6');
        Route::post('generate', 'PaymentController@generate')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'StatusController@destroy')->middleware('superadmin');
        Route::match(['get', 'put'], 'update/{id}', 'StatusController@update')->middleware('rolecheck:6');
        Route::match(['get', 'post'], 'create', 'StatusController@create')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'payment-batches'
    ], function() {
        Route::get('/', 'PaymentBatchController@index')->middleware('rolecheck:6');
        Route::get('{id}/download', 'PaymentBatchController@download')->middleware('rolecheck:6');
    });
    Route::group([
      'prefix' => 'postulations'
    ], function() {
        Route::get('/', 'PostulationController@index')->middleware('rolecheck:6');
        Route::get('/delete-expired', 'PostulationController@deleteexpired')->middleware('appenginecron');
        Route::get('/map', 'PostulationController@map')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'PostulationController@destroy')->middleware('superadmin');
    });

    Route::group([
      'prefix' => 'currentcontracts'
    ], function() {
        Route::get('/', 'ContractController@currentcontracts')->middleware('rolecheck:6');
        Route::get('/delete-missed', 'ContractController@deletemissed')->middleware('appenginecron');
        Route::get('/map', 'ContractController@mapcurrentcontracts')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'ContractController@currentdestroy')->middleware('superadmin');
        Route::get('{id}/comments', 'ContractCommentController@index')->middleware('rolecheck:6');
        Route::post('{id}/comments', 'ContractCommentController@store')->middleware('rolecheck:6');
        Route::delete('{id}/comments/{comment_id}', 'ContractCommentController@destroy')->middleware('superadmin');
    });

    Route::group([
      'prefix' => 'finishedcontracts'
    ], function() {
        Route::get('/', 'ContractController@finishedcontracts')->middleware('rolecheck:6');
        Route::get('/map', 'ContractController@mapfinishedcontracts')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'ContractController@finisheddestroy')->middleware('superadmin');
    });
    Route::group([
      'prefix' => 'reports'
    ], function() {
        Route::get('/', 'ReportController@index')->middleware('rolecheck:6');
        Route::delete('delete/{id}', 'ReportController@destroy')->middleware('superadmin');
        Route::get('{id}/comments', 'ReportCommentController@index')->middleware('rolecheck:6');
        Route::post('{id}/comments', 'ReportCommentController@store')->middleware('rolecheck:6');
        Route::delete('{id}/comments/{comment_id}', 'ReportCommentController@destroy')->middleware('superadmin');
        Route::match(['get', 'post'], 'veredict/{id}', 'ReportController@veredict')->middleware('rolecheck:6');
        //Route::match(['get', 'post'], 'create', 'CouponController@create')->middleware('rolecheck:6');
    });
});


Route::get('user/verify/{token}', 'Auth\AuthController@checkemail')->name('checkemail');

Route::get('auth/{provider}', 'Auth\LoginController@redirectToProvider');
Route::get('auth/{provider}/callback', 'Auth\LoginController@handleProviderCallback');
