snipe-it/routes/api.php

311 lines
8.9 KiB
PHP
Raw Normal View History

<?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;
/*
|--------------------------------------------------------------------------
| 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 () {
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']
]
);
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',
'show' => 'api.categories.show',
'update' => 'api.categories.update',
'store' => 'api.categories.store',
'destroy' => 'api.categories.destroy'
],
'except' => ['edit', 'create'],
'parameters' => ['category' => 'category_id']
]
);
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 () {
Route::get('{id}/deployable', function ($statuslabelId) {
$statuslabel = Statuslabel::find($statuslabelId);
if (( $statuslabel->deployable == '1' ) && ( $statuslabel->pending != '1' )
&& ( $statuslabel->archived != '1' )
) {
return '1';
} else {
return '0';
}
});
// 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',
'create' => 'api.manufacturers.create',
'destroy' => 'api.manufacturers.destroy'
],
'parameters' =>
['manufacturer' => 'manufacturer_id']
]
);
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',
'create' => 'api.accessories.create',
'destroy' => 'api.accessories.destroy'
],
'parameters' =>
['accessory' => 'accessory_id']
]
);
2016-12-14 10:54:05 -08:00
/*---Hardware API---*/
2017-01-12 02:20:32 -08:00
Route::post('hardware/import', [ 'as' => 'api.assets.importFile', 'uses'=> 'AssetsController@postAPIImportUpload']);
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',
'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
2017-01-12 02:20:32 -08:00
2016-12-14 10:54:05 -08:00
/*---Accessories API---*/
Route::group([ 'prefix' => 'accessories' ], function () {
Route::get('list', [ 'as' => 'api.accessories.list', 'uses' => 'AccessoriesController@getDatatable' ]);
Route::get(
'{accessoryID}/view',
[ 'as' => 'api.accessories.view', 'uses' => 'AccessoriesController@getDataView' ]
);
});
/*---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-12 23:41:08 -08:00
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
/*---Licenses API---*/
Route::group([ 'prefix' => 'licenses' ], function () {
Route::get('list', [ 'as' => 'api.licenses.list', 'uses' => 'LicensesController@getDatatable' ]);
});
/*---Locations API---*/
Route::group([ 'prefix' => 'locations' ], function () {
Route::get('{locationID}/check', function ($locationID) {
$location = Location::find($locationID);
return $location;
});
});
});