<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});


Route::post('/login', 'CommonController@login');

Route::get('/classify', 'ClassifyController@list');
Route::get('/classify/parent', 'ClassifyController@parent');

Route::get('/campaigns', 'CampaignController@list');

Route::get('/products', 'ProductController@list');

Route::get('/house_clean_orders', 'HouseCleanOrderController@list');
Route::get('/house_appliance_clean_orders', 'HouseApplianceCleanOrderController@list');
Route::get('/housekeeper_orders', 'HousekeeperOrderController@list');
Route::get('/option_orders', 'OptionOrderController@list');
Route::get('/maternity_matron_orders', 'MaternityMatronOrderController@list');
Route::get('/product_orders', 'ProductOrderController@list');
Route::get('/server_infos', 'ClassifyController@home');
Route::get('/classifies', 'ClassifyController@list');
Route::get('/company_info', 'HomePageController@introduce');

Route::post('/campaign/store', 'CampaignController@store');
Route::post('/product/store', 'ProductController@store');
Route::get('/product/home', 'ProductController@home');

Route::post('/payments/wechat-notify', 'PaymentController@notify');


Route::get('/classify/{classify_id}/options', 'OptionController@option_keys');
Route::get('/option/key/{id}', 'OptionController@option_key');
Route::get('/option/value/{id}', 'OptionController@option_value');


Route::get('/server_info/{id}', 'ClassifyController@server_content');
Route::get('/classify/{id}', 'ClassifyController@get');


Route::middleware(['token'])->group(function () {

    Route::get('/my/orders', 'CommonController@orders');
    Route::get('/shopcars', 'ShopcarController@list');
    Route::post('/shopcar/add', 'ShopcarController@add');
    Route::post('/shopcar/pstore', 'ShopcarController@pstore');
    Route::delete('/shopcar/{id}', 'ShopcarController@delete')->where('id', '[0-9]+');
    Route::delete('/shopcar/pdelete', 'ShopcarController@pdelete');
    Route::post('/shopcar/amount', 'ShopcarController@amount');


    Route::post('/upload', 'CommonController@upload');
    Route::post('/server/store', 'ServerInfoController@store');
    Route::get('/{order_type}/{order_id}/comments', 'CommonController@comments');
    Route::post('/{order_type}/status', 'CommonController@status');
    Route::get('/{order_type}/{id}', 'CommonController@get')->where('id', '[0-9]+');
    Route::delete('/product_order/{id}', 'ProductOrderController@delete')->where('id', '[0-9]+');
    Route::delete('/{order_type}/{id}', 'CommonController@delete')->where('id', '[0-9]+');

    Route::post('/{order_type}/{order_id}/comment', 'CommonController@addComment');
    Route::post('/house_clean_order/store', 'HouseCleanOrderController@store');
    Route::post('/house_appliance_clean_order/store', 'HouseApplianceCleanOrderController@store');
    Route::post('/housekeeper_order/store', 'HousekeeperOrderController@store');
    Route::post('/option_order/store', 'OptionOrderController@store');
    Route::post('/maternity_matron_order/store', 'MaternityMatronOrderController@store');
    Route::post('/product_order/store', 'ProductOrderController@store');
    Route::post('/server_info/store', 'ServerInfoController@store');
    Route::post('/company_info/store', 'CompanyInfoController@store');
    Route::post('/payments/pay', 'PaymentController@buildOrder');
    Route::post('/reward', 'RewardController@reward');
});

