mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-27 14:39:49 -08:00
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\Api;
|
||
|
|
||
|
use App\Models\CheckoutRequest;
|
||
|
use App\Http\Controllers\Controller;
|
||
|
use Auth;
|
||
|
use App\Helpers\Helper;
|
||
|
|
||
|
|
||
|
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) {
|
||
|
$results['rows'][] = [
|
||
|
'image' => $checkoutRequest->itemRequested()->present()->getImageUrl(),
|
||
|
'name' => $checkoutRequest->itemRequested()->present()->name(),
|
||
|
'type' => $checkoutRequest->itemType(),
|
||
|
'qty' => $checkoutRequest->quantity,
|
||
|
'location' => ($checkoutRequest->location()) ? $checkoutRequest->location()->name : null,
|
||
|
'expected_checkin' => Helper::getFormattedDateObject($checkoutRequest->itemRequested()->expected_checkin, 'datetime'),
|
||
|
'request_date' => Helper::getFormattedDateObject($checkoutRequest->created_at, 'datetime'),
|
||
|
];
|
||
|
}
|
||
|
return $results;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|