2016-12-14 04:32:10 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2016-12-14 10:54:05 -08:00
|
|
|
use App\Models\CheckoutRequest;
|
|
|
|
use App\Models\Location;
|
|
|
|
use App\Models\Statuslabel;
|
2016-12-14 04:32:10 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| 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!
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-12-14 10:54:05 -08:00
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
2017-01-25 21:29:23 -08:00
|
|
|
/*---Hardware API---*/
|
2017-01-12 23:41:08 -08:00
|
|
|
|
|
|
|
Route::resource('users', 'UsersController',
|
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.users.index',
|
|
|
|
'show' => 'api.users.show',
|
|
|
|
'update' => 'api.users.update',
|
|
|
|
'store' => 'api.users.store',
|
|
|
|
'destroy' => 'api.users.destroy'
|
|
|
|
],
|
|
|
|
'except' => ['edit'],
|
|
|
|
'parameters' => ['user' => 'user_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2017-01-24 18:58:07 -08:00
|
|
|
Route::resource('licenses', 'LicensesController',
|
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.licenses.index',
|
|
|
|
'show' => 'api.licenses.show',
|
|
|
|
'update' => 'api.licenses.update',
|
|
|
|
'store' => 'api.licenses.store',
|
|
|
|
'destroy' => 'api.licenses.destroy'
|
|
|
|
],
|
|
|
|
'except' => ['edit'],
|
|
|
|
'parameters' => ['license' => 'license_id']
|
|
|
|
]
|
|
|
|
);
|
2017-01-25 21:29:23 -08:00
|
|
|
Route::post('imports/process/{import_id}', [ 'as' => 'api.imports.importFile', 'uses'=> 'ImportController@process']);
|
|
|
|
|
|
|
|
Route::resource('imports', 'ImportController',
|
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.imports.index',
|
|
|
|
'show' => 'api.imports.show',
|
|
|
|
'update' => 'api.imports.update',
|
|
|
|
'store' => 'api.imports.store',
|
|
|
|
'destroy' => 'api.imports.destroy'
|
|
|
|
],
|
|
|
|
'except' => ['edit']
|
|
|
|
]
|
|
|
|
);
|
2017-01-24 18:58:07 -08:00
|
|
|
|
|
|
|
|
2017-01-13 04:50:20 -08:00
|
|
|
Route::resource('models', 'AssetModelsController',
|
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.models.index',
|
|
|
|
'show' => 'api.models.show',
|
|
|
|
'update' => 'api.models.update',
|
|
|
|
'store' => 'api.models.store',
|
|
|
|
'destroy' => 'api.models.destroy'
|
|
|
|
],
|
|
|
|
'except' => ['edit', 'create'],
|
|
|
|
'parameters' => ['model' => 'model_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2017-01-13 09:01:10 -08:00
|
|
|
Route::resource('categories', 'CategoriesController',
|
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.categories.index',
|
2017-01-24 17:07:00 -08:00
|
|
|
'show' => 'api.categories.asset.show',
|
2017-01-13 09:01:10 -08:00
|
|
|
'update' => 'api.categories.update',
|
|
|
|
'store' => 'api.categories.store',
|
|
|
|
'destroy' => 'api.categories.destroy'
|
|
|
|
],
|
|
|
|
'except' => ['edit', 'create'],
|
|
|
|
'parameters' => ['category' => 'category_id']
|
|
|
|
]
|
|
|
|
);
|
2017-01-13 04:50:20 -08:00
|
|
|
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('companies', 'CompaniesController',
|
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.companies.index',
|
|
|
|
'show' => 'api.companies.show',
|
|
|
|
'update' => 'api.companies.update',
|
|
|
|
'store' => 'api.companies.store',
|
|
|
|
'destroy' => 'api.companies.destroy'
|
|
|
|
],
|
|
|
|
'except' => ['edit'],
|
|
|
|
'parameters' => ['component' => 'component_id']
|
|
|
|
]
|
|
|
|
);
|
2017-01-12 19:41:01 -08:00
|
|
|
|
2017-01-13 00:13:57 -08:00
|
|
|
Route::resource('locations', 'LocationsController',
|
2017-01-12 23:41:08 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.locations.index',
|
|
|
|
'show' => 'api.locations.show',
|
|
|
|
'update' => 'api.locations.update',
|
|
|
|
'store' => 'api.locations.store',
|
|
|
|
'destroy' => 'api.locations.destroy'
|
|
|
|
],
|
|
|
|
'except' => ['edit'],
|
|
|
|
'parameters' => ['locations' => 'locations_id']
|
|
|
|
]
|
2017-01-12 19:41:01 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('components', 'ComponentsController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.components.index',
|
2017-01-12 23:41:08 -08:00
|
|
|
'show' => 'api.components.show',
|
|
|
|
'update' => 'api.components.update',
|
|
|
|
'store' => 'api.components.store',
|
2017-01-12 19:41:01 -08:00
|
|
|
'destroy' => 'api.components.destroy'
|
|
|
|
],
|
|
|
|
'parameters' =>
|
|
|
|
['component' => 'component_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('suppliers', 'SuppliersController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.suppliers.index',
|
|
|
|
'create' => 'api.suppliers.create',
|
|
|
|
'destroy' => 'api.suppliers.destroy'
|
|
|
|
],
|
|
|
|
'parameters' =>
|
|
|
|
['supplier' => 'supplier_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('users', 'UsersController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.users.index',
|
|
|
|
'create' => 'api.users.create',
|
|
|
|
'destroy' => 'api.users.destroy'
|
|
|
|
],
|
|
|
|
'parameters' =>
|
|
|
|
['user' => 'user_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('settings', 'SettingsController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.settings.index',
|
|
|
|
'create' => 'api.settings.create'
|
|
|
|
],
|
|
|
|
'parameters' =>
|
|
|
|
['setting' => 'setting_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2017-01-13 03:19:39 -08:00
|
|
|
|
|
|
|
/*---Status Label API---*/
|
|
|
|
Route::group([ 'prefix' => 'statuslabels'], function () {
|
|
|
|
|
|
|
|
|
2017-01-18 20:41:40 -08:00
|
|
|
Route::get('{id}/assetlist',
|
|
|
|
[ 'as' => 'api.statuslabels.assets', 'uses' => 'StatuslabelsController@assets' ]);
|
|
|
|
|
2017-01-24 17:37:07 -08:00
|
|
|
Route::get('{id}/deployable',
|
|
|
|
[ 'as' => 'api.statuslabels.deployable', 'uses' => 'StatuslabelsController@checkIfDeployable' ]);
|
2017-01-13 03:19:39 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Pie chart for dashboard
|
|
|
|
Route::get('assets', [ 'as' => 'api.statuslabels.assets.bytype', 'uses' => 'StatuslabelsController@getAssetCountByStatuslabel' ]);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('statuslabels', 'StatuslabelsController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.statuslabels.index',
|
|
|
|
'create' => 'api.statuslabels.create',
|
|
|
|
'destroy' => 'api.statuslabels.destroy'
|
|
|
|
],
|
|
|
|
'parameters' =>
|
|
|
|
['statuslabel' => 'statuslabel_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2017-01-13 03:19:39 -08:00
|
|
|
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('consumables', 'ConsumablesController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.consumables.index',
|
|
|
|
'create' => 'api.consumables.create',
|
|
|
|
'destroy' => 'api.consumables.destroy'
|
|
|
|
],
|
|
|
|
'parameters' =>
|
|
|
|
['consumable' => 'consumable_id']
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('manufacturers', 'ManufacturersController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.manufacturers.index',
|
2017-01-13 09:37:06 -08:00
|
|
|
'show' => 'api.manufacturers.show',
|
|
|
|
'update' => 'api.manufacturers.update',
|
|
|
|
'store' => 'api.manufacturers.store',
|
2017-01-12 19:41:01 -08:00
|
|
|
'destroy' => 'api.manufacturers.destroy'
|
|
|
|
],
|
2017-01-13 09:37:06 -08:00
|
|
|
'except' => ['edit'],
|
|
|
|
'parameters' => ['manufacturer' => 'manufacturer_id']
|
2017-01-12 19:41:01 -08:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2017-01-25 02:19:26 -08:00
|
|
|
Route::group([ 'prefix' => 'accessories' ], function () {
|
2017-01-25 04:34:11 -08:00
|
|
|
Route::match(['DELETE'], '{id}', ['uses' => 'AccessoriesController@destroy','as' => 'api.accessories.destroy']);
|
2017-01-25 02:19:26 -08:00
|
|
|
Route::get(
|
|
|
|
'{id}/checkedout',
|
|
|
|
[ 'as' => 'api.accessories.checkedout', 'uses' => 'AccessoriesController@checkedout' ]
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('accessories', 'AccessoriesController',
|
2017-01-12 19:41:01 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.accessories.index',
|
2017-01-25 02:19:26 -08:00
|
|
|
'show' => 'api.accessories.show',
|
|
|
|
'update' => 'api.accessories.update',
|
|
|
|
'store' => 'api.accessories.store',
|
2017-01-12 19:41:01 -08:00
|
|
|
'destroy' => 'api.accessories.destroy'
|
|
|
|
],
|
2017-01-25 02:19:26 -08:00
|
|
|
'except' => ['edit'],
|
|
|
|
'parameters' => ['accessory' => 'accessory_id']
|
2017-01-12 19:41:01 -08:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-14 10:54:05 -08:00
|
|
|
/*---Hardware API---*/
|
2017-01-12 02:20:32 -08:00
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::match(['DELETE'], 'hardware/{id}', ['uses' => 'AssetsController@destroy','as' => 'api.assets.destroy']);
|
2017-01-11 18:14:06 -08:00
|
|
|
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
Route::resource('hardware', 'AssetsController',
|
2017-01-11 18:14:06 -08:00
|
|
|
['names' =>
|
|
|
|
[
|
|
|
|
'index' => 'api.assets.index',
|
2017-01-11 23:40:56 -08:00
|
|
|
'create' => 'api.assets.create',
|
|
|
|
'destroy' => 'api.assets.destroy'
|
2017-01-11 18:14:06 -08:00
|
|
|
],
|
|
|
|
'parameters' =>
|
|
|
|
['asset' => 'asset_id']
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2016-12-14 10:54:05 -08:00
|
|
|
/*---Locations API---*/
|
|
|
|
Route::group(array('prefix'=>'locations'), function () {
|
2017-01-12 23:41:08 -08:00
|
|
|
|
2016-12-14 10:54:05 -08:00
|
|
|
Route::get('{locationID}/users', array('as'=>'api.locations.viewusers', 'uses'=>'LocationsController@getDataViewUsers'));
|
|
|
|
Route::get('{locationID}/assets', array('as'=>'api.locations.viewassets', 'uses'=>'LocationsController@getDataViewAssets'));
|
2017-01-24 17:37:07 -08:00
|
|
|
|
|
|
|
// Do we actually still need this, now that we have an API?
|
|
|
|
Route::get('{id}/check',
|
|
|
|
[ 'as' => 'api.locations.check', 'uses' => 'LocationsController@show' ]);
|
|
|
|
|
2016-12-14 10:54:05 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/*---Suppliers API---*/
|
|
|
|
Route::group(array('prefix'=>'suppliers'), function () {
|
|
|
|
Route::get('list', array('as'=>'api.suppliers.list', 'uses'=>'SuppliersController@getDatatable'));
|
|
|
|
});
|
|
|
|
|
|
|
|
/*---Users API---*/
|
|
|
|
Route::group([ 'prefix' => 'users' ], function () {
|
|
|
|
Route::post('/', [ 'as' => 'api.users.store', 'uses' => 'UsersController@store' ]);
|
|
|
|
Route::post('two_factor_reset', [ 'as' => 'api.users.two_factor_reset', 'uses' => 'UsersController@postTwoFactorReset' ]);
|
|
|
|
Route::get('list/{status?}', [ 'as' => 'api.users.list', 'uses' => 'UsersController@getDatatable' ]);
|
|
|
|
Route::get('{userId}/assets', [ 'as' => 'api.users.assetlist', 'uses' => 'UsersController@getAssetList' ]);
|
|
|
|
Route::post('{userId}/upload', [ 'as' => 'upload/user', 'uses' => 'UsersController@postUpload' ]);
|
|
|
|
});
|
|
|
|
|
2017-01-12 23:41:08 -08:00
|
|
|
|
2016-12-14 10:54:05 -08:00
|
|
|
|
|
|
|
|
2017-01-18 04:58:56 -08:00
|
|
|
Route::group([ 'prefix' => 'fields' ], function () {
|
|
|
|
|
|
|
|
Route::post(
|
|
|
|
'fieldsets/{id}/order',
|
|
|
|
[ 'as' => 'api.customfields.order', 'uses' => 'CustomFieldsController@postReorder' ]
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-14 10:54:05 -08:00
|
|
|
});
|
2017-01-11 14:51:00 -08:00
|
|
|
|
|
|
|
|