<?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!
|
*/
if (env('APP_ENV') === 'production') {
    URL::forceScheme('https');
}
Auth::routes(['register' => false]);

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

Route::get('/', [ 'uses' => 'PagesController@home']);
Route::get('home', [ 'uses' => 'PagesController@home'])->name('home');
Route::get('winningbidderlist', [ 'uses' => 'PagesController@winningbidderlist']);
Route::get('showwinners', [ 'uses' => 'PagesController@showwinners'])->name('showwinners');
Route::get('showscores', [ 'uses' => 'PagesController@showscores'])->name('showscores');
Route::get('showscoresbycar', [ 'uses' => 'PagesController@showscoresbycar'])->name('showscoresbycar');
Route::get('mywinnings', [ 'uses' => 'PagesController@myWinnings'])->name('mywinnings');
Route::post('mywinnings', [ 'uses' => 'PagesController@myWinnings']);

// North Embedded Checkout
Route::get('north/checkout/{bidder_id}', [ 'uses' => 'NorthCheckoutController@checkout' ])->name('north.checkout');
Route::post('north/session/{bidder_id}', [ 'uses' => 'NorthCheckoutController@createSession' ])->name('north.session');
Route::get('north/verify/{bidder_id}', [ 'uses' => 'NorthCheckoutController@verify' ])->name('north.verify');

Route::group(['middleware' => 'auth'], function() {
  Route::get('bidders', [ 'uses' => 'PagesController@bidders'])->name('bidders');
  Route::post('bidders', [ 'uses' => 'PagesController@bidders']);
  Route::get('bidderlist', [ 'uses' => 'PagesController@bidderlist'])->name('bidderlist');
  Route::post('bidderlist', [ 'uses' => 'PagesController@bidderlist']);
  Route::get('checkout', [ 'uses' => 'PagesController@checkout'])->name('checkout');
  Route::post('checkout', [ 'uses' => 'PagesController@checkout']);
  Route::get('checkout_complete_list', [ 'uses' => 'PagesController@checkoutCompleteList' ])->name('checkout_complete_list');
  Route::get('editwinners', [ 'uses' => 'PagesController@editwinners'])->name('editwinners');
  Route::post('editwinners', [ 'uses' => 'PagesController@editwinners']);
  Route::get('finaltally', [ 'uses' => 'PagesController@finaltally'])->name('finaltally');
  Route::get('items', [ 'uses' => 'PagesController@items'])->name('items');
  Route::post('items', [ 'uses' => 'PagesController@items']);
  Route::get('itemlist', [ 'uses' => 'PagesController@itemlist'])->name('itemlist');
  Route::post('itemlist', [ 'uses' => 'PagesController@itemlist']);
  Route::get('reprint_receipt', ['uses' => 'PagesController@reprintReceipt'])->name('reprint_receipt');
  Route::post('reprint_receipt', ['uses' => 'PagesController@reprintReceipt']);
  Route::get('receiptpdf', ['uses' => 'PagesController@receiptpdf'])->name('receiptpdf');
  Route::get('download_receipt', ['uses' => 'PagesController@downloadReceiptPdf'])->name('download_receipt');
  Route::get('winners', [ 'uses' => 'PagesController@winners'])->name('winners');
  Route::post('winners', [ 'uses' => 'PagesController@winners']);
  Route::get('winnerlist', [ 'uses' => 'PagesController@winnerlist'])->name('winnerlist');
  Route::post('winnerlist', [ 'uses' => 'PagesController@winnerlist']);
  Route::get('winnersbyitem', [ 'uses' => 'PagesController@winnersbyitem'])->name('winnersbyitem');
  Route::get('winnertotal', [ 'uses' => 'PagesController@winnertotal'])->name('winnertotal');
  Route::post('winnertotal', [ 'uses' => 'PagesController@winnertotal']);
  Route::get('showcars', [ 'uses' => 'PagesController@showcars'])->name('showcars');
  Route::get('judgingentry', [ 'uses' => 'PagesController@judgingentry'])->name('judgingentry');
  Route::get('pcentry', [ 'uses' => 'PagesController@pcentry'])->name('pcentry');
  Route::get('judges', [ 'uses' => 'PagesController@judges'])->name('judges');
  Route::get('vehicletypes', [ 'uses' => 'PagesController@vehicletypes'])->name('vehicletypes');
  Route::get('awardcategories', [ 'uses' => 'PagesController@awardcategories'])->name('awardcategories');
  Route::post('showcars', [ 'uses' => 'PagesController@showcars']);
  Route::post('judgingentry', [ 'uses' => 'PagesController@judgingentry']);
  Route::post('pcentry', [ 'uses' => 'PagesController@pcentry']);
  Route::post('judges', [ 'uses' => 'PagesController@judges']);
  Route::post('vehicletypes', [ 'uses' => 'PagesController@vehicletypes']);
  Route::post('awardcategories', [ 'uses' => 'PagesController@awardcategories']);
  Route::get('showcarlist', [ 'uses' => 'PagesController@showcarlist'])->name('showcarlist');
  Route::get('tabulateshowwinners', function() {
    Artisan::call('carshow:tabulatewinners');
    return redirect('showwinners');
  })->name('tabulateshowwinners');});
