<?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!
|
*/

//customer routes
Route::get('customer-register','CustomersController@register')->name('customer-register');
Route::get('customer-login','CustomersController@login')->name('customer-login');
Route::post('customer-store','CustomersController@store')->name('customer-store');
Route::post('customer-check','CustomersController@auth')->name('customer-check');
Route::get('customer-logout','CustomersController@logout')->name('customer-logout');

//search
Route::post('search','HomeController@search')->name('search');
Route::post('filter','HomeController@productFilter')->name('filter');

Route::get('/', 'HomeController@index' )->name('/');
//Route::get('/shop/{slug}',['as' => 'shop/{id}','uses' => 'HomeController@showItems' ]);
//Route::get('/{any}',  'MenuPagesController@index');
Route::get('view-product/{id}','HomeController@viewItem')->name('view-product');
Route::get('add-to-cart', 'ProductsController@addToCart')->name('add-to-cart');
Route::get('cart','ProductsController@cart')->name('cart');
Route::post('update-cart', 'ProductsController@updateCart')->name('update-cart');
Route::delete('remove-from-cart', 'ProductsController@remove');
Route::get('add-to-wishlist/{id}', 'WishlistController@addToWishlist')->name('add-to-wishlist');
Route::get('wishlist', 'WishlistController@index')->name('wishlist');
Route::delete('remove-from-wishlist', 'WishlistController@remove');
Route::post('move-to-cart','WishlistController@moveToCart')->name('move-to-cart');
Route::get('checkout','PaymentController@checkPayment')->name('checkout');
Route::post('finish-order','PaymentController@finishOrder')->name('finish-order');
Route::get('pay-order','PaymentController@payOrder')->name('pay-order');
Route::post('use-coupon','PaymentController@useCoupon')->name('use-coupon');
Route::post('get-sizes','HomeController@getSizes')->name('get-sizes');

Auth::routes();

// Route::get('/home', function() {
//     return view('home');
// })->name('home')->middleware('auth');

Route::group([
    'prefix' => 'admin',
    'middleware' => ['auth'],
],
    function () {
        /**attributes */
        Route::get('attributes','AttributesController@index')->name('admin/attributes');
        Route::get('attribute-groups','Admin\AttributesController@indexGroups')->name('admin/attrbute-groups');
        Route::get('group/{id}','Admin\AttributesController@group')->name('admin/group');
        Route::post('map-attribute','Admin\AttributesController@mapAttribute')->name('admin/map-attribute');

        /**products */
        Route::get('products', 'ProductsController@index')->name('admin/products');
        Route::get('products-view/{id}', 'ProductsController@show')->name('admin/products-view');
        Route::get('products-create','ProductsController@create')->name('admin/products-create');
        Route::post('product-store','ProductsController@store')->name('admin/product-store');
        Route::get('product-edit/{id}', 'ProductsController@edit')->name('admin.product.edit');
        Route::delete('product-delete/{id}', 'ProductsController@destroy')->name('admin.product.destroy');
        Route::get('get-attributes/{id}','ProductsController@getAttributes')->name('get-attributes');

        /**coupons */
        Route::get('coupons','Admin\CouponsController@index')->name('admin/coupons');
        Route::get('coupons-create','Admin\CouponsController@create')->name('admin/coupons-create');
        Route::post('coupon-store','Admin\CouponsController@store')->name('coupon-store');

        //categories
        Route::get('categories', 'Admin\CategoriesController@index')->name('admin/categories');
        Route::get('categories-create', 'Admin\CategoriesController@create')->name('admin/categories-create');
        Route::post('category-store', 'Admin\CategoriesController@store')->name('category-store');
        Route::get('get-categories/{id}','Admin\CategoriesController@getCategories')->name('admin/get-categories');
        Route::get('categories-edit/{id?}', 'Admin\CategoriesController@edit')->name('admin/categories-edit');
        Route::put('categories-update/{id?}', 'Admin\CategoriesController@update')->name('admin/categories.update');
        Route::delete('categories-destroy/{id?}', "Admin\CategoriesController@destroy")->name('admin/categories.destroy');

        //menu-pages
        Route::get('menu-pages','Admin\MenuPagesController@index')->name('admin\menu-pages');
        Route::get('page-create','Admin\MenuPagesController@create')->name('admin\page-create');
        Route::post('page-store','Admin\MenuPagesController@store')->name('admin\page-store');

        //banners
        Route::get('banners','Admin\BannersController@index')->name('admin\banners');
        Route::get('banners-create','Admin\BannersController@create')->name('admin\banners-create');
        Route::post('banners-store','Admin\BannersController@store')->name('admin\banners-store');

        //attributes
        Route::get('attributes','Admin\AttributesController@index')->name('attributes');
        Route::get('attributes-create','Admin\AttributesController@create')->name('admin\attributes-create');
        Route::post('attribute-store','Admin\AttributesController@store')->name('admin\attribute-store');

        //colors
        Route::get('add-set','Admin\PresetsColorController@create')->name('admin\add-set');
        Route::post('store-set','Admin\PresetsColorController@store')->name('store-set');
        Route::get('add-color/{id}','Admin\ColorController@create')->name('admin\add-color');
        Route::post('store-color','Admin\ColorController@store')->name('store-color');
        Route::get('set-view/{id}','Admin\ColorController@show')->name('admin\set-view');
        Route::get('presets','Admin\PresetsColorController@index')->name('admin\presets');

        //attribute-colors
        Route::get('attribute-colors','Admin\AttributesController@indexColors')->name('admin\attribute-colors');
        Route::get('attribute-colors-create','Admin\AttributesController@attributeColorCreate')->name('admin\attribute-color-create');
        Route::post('attribute-color-store','Admin\AttributesController@attributeColorStore')->name('admin\attribute-color-store');
        //importer
        Route::get('importer','Admin\ImporterController@index')->name('admin\importer');
        Route::post('importer/import','Admin\ImporterController@import')->name('admin\importer\import');

        //customers
        Route::get('customers','Admin\CustomersController@index');

        //merchants
        Route::get('merchant/create','Admin\MerchantsController@create')->name('admin.merchant.create');
        Route::post('merchant/store','Admin\MerchantsController@store')->name('admin.merchant.store');
        Route::get('merchants','Admin\MerchantsController@index');
        Route::get('merchant/edit/{id}','Admin\MerchantsController@edit')->name('admin.merchant.edit');
        Route::post('merchant/update','Admin\MerchantsController@update')->name('admin.merchant.update');
        Route::post('merchant/delete','Admin\MerchantsController@destroy')->name('admin.merchant.destroy');



    });

    Route::post('/ajax-autocomplete-search', 'HomeController@selectSearch');
    Route::post('/price-filter','HomeController@filterPrice');
    Route::post('/sort-filter/{category}','HomeController@sort');

// route any

Route::get('{slug}',['as'=>'slug', 'uses' => 'HomeController@showItems'])->where('slug', '([A-Za-z0-9\-\/]+)');
Route::get('{any}', ['as' => 'any', 'uses' => 'MenuPagesController@index']);
