Also related to #3888

This commit is contained in:
snipe 2017-08-26 15:21:38 -07:00
parent fba3949530
commit bf157773c8
2 changed files with 17 additions and 1 deletions

View file

@ -9,6 +9,7 @@ use App\Models\Company;
use App\Models\User;
use App\Helpers\Helper;
use App\Http\Requests\SaveUserRequest;
use App\Models\Asset;
class UsersController extends Controller
{
@ -182,4 +183,19 @@ class UsersController extends Controller
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.error.delete')));
}
/**
* Return JSON containing a list of assets assigned to a user.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0]
* @param $userId
* @return string JSON
*/
public function assets($id)
{
$this->authorize('view', User::class);
$assets = Asset::where('assigned_to', '=', $id)->with('model')->get();
return response()->json($assets);
}
}

View file

@ -540,7 +540,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
Route::get('{user}/assets',
[
'as' => 'api.users.assetlist',
'uses' => 'UsersController@getAssetList'
'uses' => 'UsersController@assets'
]
);