cancelled scaffolded out
This commit is contained in:
parent
3ee008e871
commit
79e6eafafa
4 changed files with 18 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Actions\CheckoutRequests\CancelCheckoutRequest;
|
||||
use App\Actions\CheckoutRequests\CreateCheckoutRequest;
|
||||
use App\Exceptions\AssetNotRequestable;
|
||||
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 :)'));
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy(Asset $asset): JsonResponse
|
||||
{
|
||||
CancelCheckoutRequest::run($asset, auth()->user());
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.requests.canceled')));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\CheckoutRequests\CancelCheckoutRequest;
|
||||
use App\Actions\CheckoutRequests\CreateCheckoutRequest;
|
||||
use App\Exceptions\AssetNotRequestable;
|
||||
use App\Models\Actionlog;
|
||||
|
@ -161,12 +162,11 @@ class ViewAssetsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
//public function destroy(Asset $asset): RedirectResponse
|
||||
//{
|
||||
// try {
|
||||
// CancelCheckoutRequest($asset, auth()->user());
|
||||
// }
|
||||
//}
|
||||
public function destroy(Asset $asset): RedirectResponse
|
||||
{
|
||||
CancelCheckoutRequest::run($asset, auth()->user());
|
||||
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.success'));
|
||||
}
|
||||
|
||||
|
||||
public function getRequestedAssets() : View
|
||||
|
|
|
@ -41,6 +41,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
|
|||
)->name('api.assets.requested');
|
||||
|
||||
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',
|
||||
[
|
||||
|
|
|
@ -302,7 +302,10 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
|
|||
Route::get('requestable-assets', [ViewAssetsController::class, 'getRequestableIndex'])->name('requestable-assets');
|
||||
|
||||
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'])
|
||||
->name('account/request-item');
|
||||
|
|
Loading…
Add table
Reference in a new issue