snipe-it/routes/web/hardware.php
Daniel Meltzer 64d649be7f Monster: Cleanup/Refactor http controllers. (#5916)
* Extract a handlesimages trait to centralize logic for parsing/storing images on upload in create/edit methods.

* Use same image upload/layout in accessories as consum+components.

* Monster: Cleanup/Refactor http controllers.

This cleans up docblocks, pulls most non-crudy actions into their own
controllers, and does general cleanup/logic refactoring.  There /should/
be no functional changes, but we all know how should works..

Extract checkin/checkout functions to a separate controller for accessories.

Move controllers to subdirectory.

Cleanup AssetModelsController

Extract component checkin/checkout

Assorted cleanups/doc/formatting in controllers.

Refactor LicenseController.

Refactor UsersController

Update viewassetscontroller.

* Codacy cleanups

* More codacy cleanups.  Extract a LicenseCheckout Form request as well.

* A bit more refactor/cleaning of the license checkout method.

* Review Related Cleanups

* Fix most of the item_not_found translations.  In many cases, the
string being generated did not even use the id parameter.  Where it
does, pass it as id instead of as a different value.

* Remove some old $data arrays from when we manually sent emails from
the controllers.  This has been superseeded by the notification system
(yay!)

* Bugfix: Only log the checkin of an accessory if the checkin completes sucessfully.
2018-07-24 19:35:26 -07:00

150 lines
4.6 KiB
PHP

<?php
/*
|--------------------------------------------------------------------------
| Asset Routes
|--------------------------------------------------------------------------
|
| Register all the asset routes.
|
*/
Route::group(
['prefix' => 'hardware',
'middleware' => ['auth']],
function () {
Route::get( 'bulkaudit', [
'as' => 'assets.bulkaudit',
'uses' => 'Assets\AssetsController@quickScan'
]);
# Asset Maintenances
Route::resource('maintenances', 'AssetMaintenancesController', [
'parameters' => ['maintenance' => 'maintenance_id', 'asset' => 'asset_id']
]);
Route::get('requested', [ 'as' => 'assets.requested', 'uses' => 'Assets\AssetsController@getRequestedIndex']);
Route::get('scan', [
'as' => 'asset.scan',
'uses' => 'Assets\AssetsController@scan'
]);
Route::get('audit/{id}', [
'as' => 'asset.audit.create',
'uses' => 'Assets\AssetsController@audit'
]);
Route::post('audit/{id}', [
'as' => 'asset.audit.store',
'uses' => 'Assets\AssetsController@auditStore'
]);
Route::get('history', [
'as' => 'asset.import-history',
'uses' => 'Assets\AssetsController@getImportHistory'
]);
Route::post('history', [
'as' => 'asset.process-import-history',
'uses' => 'Assets\AssetsController@postImportHistory'
]);
Route::get('/bytag', [
'as' => 'findbytag/hardware',
'uses' => 'Assets\AssetsController@getAssetByTag'
]);
Route::get('{assetId}/clone', [
'as' => 'clone/hardware',
'uses' => 'Assets\AssetsController@getClone'
]);
Route::post('{assetId}/clone', 'Assets\AssetsController@postCreate');
Route::get('{assetId}/checkout', [
'as' => 'checkout/hardware',
'uses' => 'Assets\AssetCheckoutController@create'
]);
Route::post('{assetId}/checkout', [
'as' => 'checkout/hardware',
'uses' => 'Assets\AssetCheckoutController@store'
]);
Route::get('{assetId}/checkin/{backto?}', [
'as' => 'checkin/hardware',
'uses' => 'Assets\AssetCheckinController@create'
]);
Route::post('{assetId}/checkin/{backto?}', [
'as' => 'checkin/hardware',
'uses' => 'Assets\AssetCheckinController@store'
]);
Route::get('{assetId}/view', [
'as' => 'hardware.view',
'uses' => 'Assets\AssetsController@show'
]);
Route::get('{assetId}/qr_code', [ 'as' => 'qr_code/hardware', 'uses' => 'Assets\AssetsController@getQrCode' ]);
Route::get('{assetId}/barcode', [ 'as' => 'barcode/hardware', 'uses' => 'Assets\AssetsController@getBarCode' ]);
Route::get('{assetId}/restore', [
'as' => 'restore/hardware',
'uses' => 'Assets\AssetsController@getRestore'
]);
Route::post('{assetId}/upload', [
'as' => 'upload/asset',
'uses' => 'Assets\AssetFilesController@store'
]);
Route::get('{assetId}/showfile/{fileId}/{download?}', [
'as' => 'show/assetfile',
'uses' => 'Assets\AssetFilesController@show'
]);
Route::delete('{assetId}/showfile/{fileId}/delete', [
'as' => 'delete/assetfile',
'uses' => 'Assets\AssetFilesController@destroy'
]);
Route::post(
'bulkedit',
[
'as' => 'hardware/bulkedit',
'uses' => 'Assets\BulkAssetsController@edit'
]
);
Route::post(
'bulkdelete',
[
'as' => 'hardware/bulkdelete',
'uses' => 'Assets\BulkAssetsController@destroy'
]
);
Route::post(
'bulksave',
[
'as' => 'hardware/bulksave',
'uses' => 'Assets\BulkAssetsController@update'
]
);
# Bulk checkout / checkin
Route::get( 'bulkcheckout', [
'as' => 'hardware/bulkcheckout',
'uses' => 'Assets\BulkAssetsController@showCheckout'
]);
Route::post( 'bulkcheckout', [
'as' => 'hardware/bulkcheckout',
'uses' => 'Assets\BulkAssetsController@storeCheckout'
]);
});
Route::resource('hardware', 'Assets\AssetsController', [
'middleware' => ['auth'],
'parameters' => ['asset' => 'asset_id']
]);