mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 14:09:43 -08:00
934afa036f
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
46 lines
1.5 KiB
PHP
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' => $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;
|
|
}
|
|
}
|