snipe-it/app/Http/Controllers/Api/ProfileController.php
snipe 9aac1cbba4 Merge branch 'master' into rcs/merge_master_into_develop_for_rc_8
Signed-off-by: snipe <snipe@snipe.net>

# Conflicts:
#	README.md
#	app/Console/Commands/MoveUploadsToNewDisk.php
#	app/Http/Controllers/ActionlogController.php
#	app/Http/Controllers/Api/LicensesController.php
#	app/Http/Controllers/Api/StatuslabelsController.php
#	app/Http/Controllers/Assets/AssetCheckinController.php
#	app/Http/Controllers/Licenses/LicensesController.php
#	app/Http/Controllers/Users/BulkUsersController.php
#	app/Http/Requests/AssetCheckoutRequest.php
#	app/Importer/LicenseImporter.php
#	app/Models/Actionlog.php
#	app/Models/License.php
#	app/Models/User.php
#	app/Observers/AssetObserver.php
#	composer.lock
#	config/version.php
#	database/factories/LicenseFactory.php
#	database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php
#	database/migrations/2018_10_18_191228_add_kits_licenses_table.php
#	database/migrations/2018_10_19_153910_add_kits_table.php
#	database/migrations/2018_10_19_154013_add_kits_models_table.php
#	database/migrations/2019_02_07_185953_add_kits_consumables_table.php
#	database/migrations/2019_02_07_190030_add_kits_accessories_table.php
#	package-lock.json
#	package.json
#	public/css/dist/all.css
#	public/css/dist/bootstrap-table.css
#	public/js/dist/bootstrap-table.js
#	public/mix-manifest.json
#	resources/lang/ar/general.php
#	resources/lang/ar/passwords.php
#	resources/lang/cs/general.php
#	resources/lang/cs/passwords.php
#	resources/lang/de/admin/custom_fields/general.php
#	resources/lang/de/admin/settings/general.php
#	resources/lang/de/admin/settings/message.php
#	resources/lang/fr/admin/custom_fields/general.php
#	resources/lang/fr/admin/hardware/general.php
#	resources/lang/fr/admin/locations/table.php
#	resources/lang/fr/admin/settings/message.php
#	resources/lang/hu/admin/custom_fields/general.php
#	resources/lang/hu/admin/settings/general.php
#	resources/lang/hu/general.php
#	resources/lang/it/admin/settings/general.php
#	resources/lang/nl/admin/custom_fields/general.php
#	resources/lang/nl/admin/settings/general.php
#	resources/lang/nl/general.php
#	resources/lang/pl/admin/custom_fields/general.php
#	resources/lang/sv-SE/passwords.php
#	resources/lang/tr/general.php
#	resources/views/hardware/view.blade.php
#	resources/views/partials/bootstrap-table.blade.php
#	resources/views/reports/activity.blade.php
#	resources/views/users/print.blade.php
2022-04-28 17:49:06 +01:00

46 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Models\CheckoutRequest;
use Auth;
class ProfileController extends Controller
{
/**
* Display a listing of requested assets.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.3.0]
*
* @return array
*/
public function requestedAssets()
{
$checkoutRequests = CheckoutRequest::where('user_id', '=', Auth::user()->id)->get();
$results = [];
$results['total'] = $checkoutRequests->count();
foreach ($checkoutRequests as $checkoutRequest) {
// Make sure the asset and request still exist
if ($checkoutRequest && $checkoutRequest->itemRequested()) {
$results['rows'][] = [
'image' => e($checkoutRequest->itemRequested()->present()->getImageUrl()),
'name' => e($checkoutRequest->itemRequested()->present()->name()),
'type' => e($checkoutRequest->itemType()),
'qty' => (int) $checkoutRequest->quantity,
'location' => ($checkoutRequest->location()) ? e($checkoutRequest->location()->name) : null,
'expected_checkin' => Helper::getFormattedDateObject($checkoutRequest->itemRequested()->expected_checkin, 'datetime'),
'request_date' => Helper::getFormattedDateObject($checkoutRequest->created_at, 'datetime'),
];
}
}
return $results;
}
}