<?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::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('/{order_type}/{id}', 'CommonController@delete')->where('id', '[0-9]+');

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

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('/maternity_matron_orders', 'MaternityMatronOrderController@list');
Route::get('/product_orders', 'ProductOrderController@list');
Route::get('/server_infos', 'ServerInfoController@list');
Route::get('/server_fields', 'CommonController@server_json');
Route::get('/classifies', 'ClassifyController@list');
Route::get('/company_info', 'CompanyInfoController@info');

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


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


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

    Route::get('/my/orders', 'CommonController@orders');
    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('/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');
});

