cancelled scaffolded out

This commit is contained in:
spencerrlongg 2024-10-22 22:33:29 -05:00
parent 3ee008e871
commit 79e6eafafa
4 changed files with 18 additions and 7 deletions

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Actions\CheckoutRequests\CancelCheckoutRequest;
use App\Actions\CheckoutRequests\CreateCheckoutRequest; use App\Actions\CheckoutRequests\CreateCheckoutRequest;
use App\Exceptions\AssetNotRequestable; use App\Exceptions\AssetNotRequestable;
use App\Helpers\Helper; use App\Helpers\Helper;
@ -26,4 +27,10 @@ class CheckoutRequest extends Controller
return response()->json(Helper::formatStandardApiResponse('error', null, 'Something terrible has gone wrong and we\'re not sure if we can help - may god have mercy on your soul. Contact your admin :)')); return response()->json(Helper::formatStandardApiResponse('error', null, 'Something terrible has gone wrong and we\'re not sure if we can help - may god have mercy on your soul. Contact your admin :)'));
} }
} }
public function destroy(Asset $asset): JsonResponse
{
CancelCheckoutRequest::run($asset, auth()->user());
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.requests.canceled')));
}
} }

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Actions\CheckoutRequests\CancelCheckoutRequest;
use App\Actions\CheckoutRequests\CreateCheckoutRequest; use App\Actions\CheckoutRequests\CreateCheckoutRequest;
use App\Exceptions\AssetNotRequestable; use App\Exceptions\AssetNotRequestable;
use App\Models\Actionlog; use App\Models\Actionlog;
@ -161,12 +162,11 @@ class ViewAssetsController extends Controller
} }
} }
//public function destroy(Asset $asset): RedirectResponse public function destroy(Asset $asset): RedirectResponse
//{ {
// try { CancelCheckoutRequest::run($asset, auth()->user());
// CancelCheckoutRequest($asset, auth()->user()); return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success'));
// } }
//}
public function getRequestedAssets() : View public function getRequestedAssets() : View

View file

@ -41,6 +41,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
)->name('api.assets.requested'); )->name('api.assets.requested');
Route::post('request/{asset}', [Api\CheckoutRequest::class, 'store'])->name('api.assets.requests.store'); Route::post('request/{asset}', [Api\CheckoutRequest::class, 'store'])->name('api.assets.requests.store');
Route::post('request/{asset}/cancel', [Api\CheckoutRequest::class, 'destroy'])->name('api.assets.requests.destroy');
Route::get('requestable/hardware', Route::get('requestable/hardware',
[ [

View file

@ -302,7 +302,10 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
Route::get('requestable-assets', [ViewAssetsController::class, 'getRequestableIndex'])->name('requestable-assets'); Route::get('requestable-assets', [ViewAssetsController::class, 'getRequestableIndex'])->name('requestable-assets');
Route::post('request-asset/{asset}', [ViewAssetsController::class, 'store']) Route::post('request-asset/{asset}', [ViewAssetsController::class, 'store'])
->name('account/request-asset'); ->name('account.request-asset');
Route::post('request-asset/{asset}/cancel', [ViewAssetsController::class, 'destroy'])
->name('account.request-asset.cancel');
Route::post('request/{itemType}/{itemId}/{cancel_by_admin?}/{requestingUser?}', [ViewAssetsController::class, 'getRequestItem']) Route::post('request/{itemType}/{itemId}/{cancel_by_admin?}/{requestingUser?}', [ViewAssetsController::class, 'getRequestItem'])
->name('account/request-item'); ->name('account/request-item');