snipe-it/app/Http/Controllers/Api/CheckoutRequest.php
spencerrlongg 1fd945c2d8 this works
2024-10-17 12:45:49 -05:00

24 lines
892 B
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Actions\CheckoutRequests\CreateCheckoutRequest;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CheckoutRequest extends Controller
{
public function store($assetId): JsonResponse
{
$status = CreateCheckoutRequest::run($assetId);
return match ($status) {
'doesNotExist' => response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist_or_not_requestable'))),
'accessDenied' => response()->json(Helper::formatStandardApiResponse('error', null, trans('general.insufficient_permissions'))),
default => response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.request_successfully_created'))),
};
}
}