<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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('/', 'ContactFormController@create') ->name('skill');
Route::post('/', 'ContactFormController@store');

Auth::routes();

//tutorial popup for new users
//Route::get('newUserTutorial', 'RegisterController@newUserTutorial')->name('splash');

//images routes
//Route::get('image-upload', 'ImageUploadController@imageUpload')->name('image.upload');
//Route::post('image-upload', 'ImageUploadController@imageUploadPost')->name('image.upload.post');

Route::get('modal-upload', 'ModalController@modalEdit')->name('modal.upload');
Route::post('modal-upload', 'ModalController@modalEditPost')->name('modal.upload.post');

Route::post('/create-profile', ['middleware' => 'mobile', 'uses' => 'MobileController@createPlayer']);
Route::post('/upload-data', ['middleware' => 'mobile', 'uses' => 'MobileController@uploadData']);
Route::post('/sync-login', ['middleware' => 'mobile', 'uses' => 'MobileController@login']);
Route::post('/redirect', ['middleware' => 'mobile', 'uses' => 'MobileController@redirect']);

Route::get('admin/home', 'ClubController@noparam')->name('admin');

Route::get('/new_user', 'LoginController@authenticated')->name('new_user');

Route::get('/club/{clubid?}', 'ClubController@index')->name('home');

Route::get('/player/home/{playerid?}', 'PlayerDashController@index')->name('player');
Route::get('/player/{playerid?}', 'PlayerController@index')->name('home');
Route::get('/player/{playerid?}', 'PlayerController@index')->name('home')->middleware('auth');

Route::group(['middleware' => 'auth'], function () {
    Route::get('new_user', ['as' => 'pages.new_user', 'uses' => 'PageController@new_user']);
    Route::get('maps', ['as' => 'pages.maps', 'uses' => 'PageController@maps']);
    Route::get('notifications', ['as' => 'pages.notifications', 'uses' => 'PageController@notifications']);
    Route::get('rtl', ['as' => 'pages.rtl', 'uses' => 'PageController@rtl']);
    Route::get('tutorial', ['as' => 'pages.tutorial', 'uses' => 'PageController@tables']);
    Route::get('typography', ['as' => 'pages.typography', 'uses' => 'PageController@typography']);
    Route::get('upgrade', ['as' => 'pages.upgrade', 'uses' => 'PageController@upgrade']);
    Route::get('leaderboard', ['as' => 'pages.leaderboard', 'uses' => 'PageController@leaderboard']);
});

Route::group(['middleware' => 'auth'], function () {
    Route::resource('user', 'UserController', ['except' => ['show']]);
    Route::get('profile', ['as' => 'profile.edit', 'uses' => 'ProfileController@edit']);
    Route::put('profile', ['as' => 'profile.update', 'uses' => 'ProfileController@update']);
    Route::put('profile/club', ['as' => 'profile.club', 'uses' => 'ProfileController@club']);

    Route::put('profile/password', ['as' => 'profile.password', 'uses' => 'ProfileController@password']);

    Route::get('/search', 'ClubController@search');
});
