mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
This commit is contained in:
parent
7982b3f237
commit
5281713fd9
|
@ -5,10 +5,12 @@ use App\Helpers\Helper;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AssetCheckoutRequest;
|
||||
use App\Http\Transformers\AssetsTransformer;
|
||||
use App\Http\Transformers\LicensesTransformer;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Company;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\License;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
|
@ -332,7 +334,14 @@ class AssetsController extends Controller
|
|||
|
||||
|
||||
}
|
||||
|
||||
public function licenses($id)
|
||||
{
|
||||
$this->authorize('view', Asset::class);
|
||||
$this->authorize('view', License::class);
|
||||
$asset = Asset::where('id', $id)->withTrashed()->first();
|
||||
$licenses = $asset->licenses()->get();
|
||||
return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a paginated collection for the select2 menus
|
||||
|
|
|
@ -304,7 +304,12 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
|||
/*--- Hardware API ---*/
|
||||
|
||||
Route::group(['prefix' => 'hardware'], function () {
|
||||
|
||||
|
||||
Route::get('{asset_id}/licenses', [
|
||||
'as' => 'api.assets.licenselist',
|
||||
'uses' => 'AssetsController@licenses'
|
||||
]);
|
||||
|
||||
Route::get( 'bytag/{tag}', [
|
||||
'as' => 'assets.show.bytag',
|
||||
'uses' => 'AssetsController@showByTag'
|
||||
|
|
Loading…
Reference in a new issue