2018-04-04 17:33:02 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
2019-03-13 20:12:03 -07:00
|
|
|
use App\Helpers\Helper;
|
2018-04-04 17:33:02 -07:00
|
|
|
use App\Http\Controllers\Controller;
|
2019-03-13 20:12:03 -07:00
|
|
|
use App\Models\CheckoutRequest;
|
2018-04-04 17:33:02 -07:00
|
|
|
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) {
|
2019-03-05 23:46:40 -08:00
|
|
|
|
|
|
|
// Make sure the asset and request still exist
|
|
|
|
if ($checkoutRequest && $checkoutRequest->itemRequested()) {
|
|
|
|
$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'),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-04-04 17:33:02 -07:00
|
|
|
}
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|