mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 23:54:12 -08:00
8a6713d5c0
* WIP - beginning of improved requested assets - Use Ajax tables for faster loading - Use new notifications for requesting an asset TODO: - Use ajax tables for requestable asset models - Use new notifications for canceling an asset request - Expire requests once the asset has been checked out to the requesting user * Only show asset name in email if it has one * Refactor requested method to only include non-canceled requests * Refactored requestable assets to log request and cancelation * Added softdeletes on checkout requests * Differentiate between canceling and deleting requests * Added asset request cancelation notification * Added timestamps and corrected unique key on requests table * Improved requests view * Re-use blade for cancel/request email * Refactored BS table formatter for requested assets * Location name min reduced to 2 * Added PAT test as maintenance option This needs to be refactored into database-driven options with a UI * Better slack message * Added getImageUrl method for assets * Include qty in request notifications TODO: - Try to pull requested info from original request for cancelation, otherwise it will default to 1 * Removed old asset request/cancel emails * Added user profile asset request routes * Added profile controller requested assets method * Added blade link to requested assets for profile view * Sort user history desc * Added requested assets blade * Added canceled at to checkoutRequest method * Include qty in request * Fixed comment, removed allowed_columns * Removed Queable methods, since we don’t use a queue * Fixed return type in method doc * Fixed version number * Changed id to user_id for clarity
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;
|
|
}
|
|
|
|
|
|
}
|