<?php

/*
|--------------------------------------------------------------------------
| Module Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for this module.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::group(['prefix' => Config::get('app.api_path'), 'middleware' => ['web', 'auth']], function () {
    Route::resource('stock', 'App\Modules\Stock\StockControllerRESTv1');
    Route::resource('stockitems', 'App\Modules\Stock\StockItemControllerRESTv1');
    Route::resource('stockgroups', 'App\Modules\Stock\StockGroupsControllerREST');
    Route::resource('suppliers', 'App\Modules\Stock\SuppliersControllerREST');
    Route::resource('transactions', 'App\Modules\Stock\StockTransactionControllerRESTv1', ['names' => [
        'index' => 'stock.transactions.index',
        'create' => 'stock.transactions.create',
        'store' => 'stock.transactions.store',
        'show' => 'stock.transactions.show',
        'edit' => 'stock.transactions.edit',
        'update' => 'stock.transactions.update',
        'destroy' => 'stock.transactions.destroy',
    ]]);
    Route::resource('orders/items', 'App\Modules\Stock\StockPurchaseOrderItemControllerRESTv1', ['names' => [
        'index' => 'stock.orders.items.index',
        'create' => 'stock.orders.items.create',
        'store' => 'stock.orders.items.store',
        'show' => 'stock.orders.items.show',
        'edit' => 'stock.orders.items.edit',
        'update' => 'stock.orders.items.update',
        'destroy' => 'stock.orders.items.destroy',
    ]]);
    Route::resource('orders', 'App\Modules\Stock\StockPurchaseOrdersControllerRESTv1', ['names' => [
        'index' => 'stock.orders.index',
        'create' => 'stock.orders.create',
        'store' => 'stock.orders.store',
        'show' => 'stock.orders.show',
        'edit' => 'stock.orders.edit',
        'update' => 'stock.orders.update',
        'destroy' => 'stock.orders.destroy',
    ]]);
    Route::post('orders/sync-to-xero/{id}', 'App\Modules\Stock\StockPurchaseOrdersControllerRESTv1@syncToXero');
    Route::get('stock/overview/activity', 'App\\Modules\\Stock\\StockOverviewV1@getActivity');
    Route::get('stock/helpers/activity', 'App\\Modules\\Stock\\HelpersControllerREST@getActivity');
    Route::resource('stock_reports', 'App\Modules\Stock\StockReportsControllerRESTv1');
    Route::resource('payments', 'App\Modules\Stock\PaymentsControllerRESTv1');
});

/*
|--------------------------------------------------------------------------
| Pages rendered on the server
|--------------------------------------------------------------------------
|
| This group routes are pages rendered on the server.
| All the pages require the user to be authentificated.
|
*/

Route::group(['middleware' => ['web', 'auth']], function () {
    Route::get('stock', 'App\\Modules\\Stock\\StockController@getIndex');
    Route::get('stock/barcode/{id}', 'App\\Modules\\Stock\\StockController@getBarcode');
});
