<?php

Route::post('fatoni/generate/api', array('as' => 'fatoni.generate.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@generateApi'));
Route::post('fatoni/update/api/{id}', array('as' => 'fatoni.update.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@updateApi'));
Route::get('fatoni/delete/api/{id}', array('as' => 'fatoni.delete.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@deleteApi'));

Route::group(['prefix' =>'api/v1','namespace' =>'AhmadFatoni\ApiGenerator\Controllers\API'],function ($route){
    Route::get('sms', 'SmsApiController@index');
    
    Route::resource('categories', 'CategoriesAPIController', ['except' => ['destroy', 'create', 'edit']]);
    Route::get('category/{id}/subs', ['as' => 'category.subs', 'uses' => 'CategoriesAPIController@subs']);
    
    

    Route::get('product/{id}/add-wishlist', ['as' => 'create.fav', 'uses' => 'ProductsApiController@createFav']);
    
    

    Route::get('products', ['as' => 'products.index', 'uses' => 'ProductsApiController@index']);
  
    
    Route::get('category/filters', 'CategoriesAPIController@getFilters');
    
    Route::get('home', 'BlogPostsApiController@home');
   // Route::get('products', 'ProductsApiController@index');
    Route::get('products/{id}', ['as' => 'products.show', 'uses' => 'ProductsApiController@show']);
    Route::get('test',['as' => 'test', 'uses' => 'SmsController@index']);

    // Route::get('products/{id}/delete', ['as' => 'products.delete', 'uses' => 'ProductsApiController@destroy']);


    Route::resource('terms', 'TermsapiController', ['except' => ['destroy', 'create', 'edit']]);
    // Route::get('terms/{id}/delete', ['as' => 'terms.delete', 'uses' => 'TermsapiController@destroy']);

    Route::post('send-contact-form', 'ContactFormApiController@sendContactForm');
    
    Route::post('search', 'ProductsApiController@searchProd');

    Route::get('news', 'BlogPostsApiController@index');
    Route::get('news/{id}', 'BlogPostsApiController@show')->where(['id' => '[0-9]+']);

    Route::get('sliders', 'BlogPostsApiController@getSliders');
    
    Route::get('places', 'BlogPostsApiController@getPlaces');
    Route::get('places/{id}/subs', ['as' => 'place.subs', 'uses' => 'BlogPostsApiController@getSubPlaces']);
    
    Route::get('accounts', 'BlogPostsApiController@getAccounts');
    
    Route::get('get/product/comments', 'BlogPostsApiController@getProductComment');
    
    Route::get('notifications', 'BlogPostsApiController@getNotifications');
    
//    Route::get('account/{id}/sliders', 'BlogPostsApiController@getAccountSliders')->where(['id' => '[0-9]+']);
    Route::get('account/{id}/products', 'BlogPostsApiController@getAccountProducts')->where(['id' => '[0-9]+']);
    Route::get('account/{id}/datas', 'BlogPostsApiController@getAccountDatas');
    
    Route::get('get/category/datas', 'BlogPostsApiController@getCategoryDatas');
    
    Route::get('get/all/sub/products', 'BlogPostsApiController@getProductsWithAllSubCats');

    Route::middleware(['\Tymon\JWTAuth\Middleware\GetUserFromToken'])->group(function () {
        Route::delete('delete/account', 'VendorApiController@deleteVendor');
        
        
        Route::post('update/products/{id}', 'ProductsApiController@update');
        Route::post('update/status/{id}', 'ProductsApiController@updateStatus');
        Route::delete('delete/product/{id}', 'ProductsApiController@delete');
        Route::delete('products/{id}/image-delete/{image_id}', 'ProductsApiController@imageDelete')
            ->where(['id' => '[0-9]+', 'image_id' => '[0-9]+']);
        Route::post('update/product/ends_at/{id}', 'ProductsApiController@updateEndsAt');  
        
        Route::post('make/order', 'OrderApiController@createOrder');
        Route::get('my/orders', 'OrderApiController@myOrders');
        Route::get('vendor/sale/orders', 'OrderApiController@mySaleOrders');
        Route::get('vendor/sales', 'OrderApiController@mySales');
        Route::post('vendor/confirm/order', 'OrderApiController@confirmOrder');
        Route::get('check/vendor/sales', 'OrderApiController@checkVendorSales');
        Route::get('pdf/order/products', 'OrderApiController@createPdf');
        
        Route::post('update/vendor/data', 'VendorApiController@updateVendor');
        
        Route::post('create/fav', 'BlogPostsApiController@createFav');
        Route::get('get/fav', 'BlogPostsApiController@getFav');
        Route::delete('fav/{id}', 'BlogPostsApiController@deleteFav');
        
        Route::post('create/comment', 'BlogPostsApiController@createComment');
        Route::get('get/customer/comments', 'BlogPostsApiController@getComment');

        Route::post('products', 'ProductsApiController@store');
        Route::post('products/{id}', 'ProductsApiController@update')->where('id', '[0-9]+');
        
        Route::delete('products/{id}/image-delete/{image_id}', 'ProductsApiController@imageDelete')
            ->where(['id' => '[0-9]+', 'image_id' => '[0-9]+']);
        Route::post('products/{id}/publish', 'ProductsApiController@publish')
            ->where('id', '[0-9]+');
            
            
        Route::get('my-products','ProductsApiController@myProducts');
        Route::get('my-products/{id}','ProductsApiController@showMyProductById');
        Route::delete('my-products/{id}', 'ProductsApiController@delete')
            ->where('id', '[0-9]+');
            
            
        Route::resource('messages', 'MessagesapiController', ['except' => ['destroy', 'create', 'edit']]);
        Route::get('messages/chatroom/{id}', 'MessagesapiController@enterChatroom')
            ->where('id', '[0-9]+');
        Route::get('messages/chatroom/{id}/load-more', 'MessagesapiController@loadMore')
            ->where('id', '[0-9]+');
        Route::post('messages/{chatroom_id}', 'MessagesapiController@sendMessage')
            ->where('chatroom_id', '[0-9]+');
        Route::post('messages/initialize-chatting/{seller_id}', 'MessagesapiController@initializeChatting')
            ->where('seller_id', '[0-9]+');

        //Balance

        // Route::post('balance_bank_transfer','BalanceController@createBankTransfer');
    });

    Route::get('bank-info', 'BanksApiController@getBankInfo');
    Route::get('bank-types', 'BanksApiController@getBankTypes');
    
});

