this is pretty much done

This commit is contained in:
spencerrlongg 2024-10-23 01:41:27 -05:00
parent b0d7eb2168
commit fdb6970f36
3 changed files with 17 additions and 13 deletions

View file

@ -12,6 +12,7 @@ use App\Models\User;
use App\Notifications\RequestAssetCancelation; use App\Notifications\RequestAssetCancelation;
use App\Notifications\RequestAssetNotification; use App\Notifications\RequestAssetNotification;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Log;
class CreateCheckoutRequest class CreateCheckoutRequest
{ {
@ -47,16 +48,9 @@ class CreateCheckoutRequest
try { try {
$settings->notify(new RequestAssetNotification($data)); $settings->notify(new RequestAssetNotification($data));
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::warning($e); Log::warning($e);
} }
return true; // or $asset, or whatever return true;
} }
public function doSomethingElse()
{
}
} }

View file

@ -30,7 +30,12 @@ class CheckoutRequest extends Controller
public function destroy(Asset $asset): JsonResponse public function destroy(Asset $asset): JsonResponse
{ {
CancelCheckoutRequest::run($asset, auth()->user()); try {
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.requests.canceled'))); CancelCheckoutRequest::run($asset, auth()->user());
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.requests.canceled')));
} catch (\Exception $e) {
report($e);
return response()->json(Helper::formatStandardApiResponse('error', null, $e->getMessage()));
}
} }
} }

View file

@ -164,8 +164,13 @@ class ViewAssetsController extends Controller
public function destroy(Asset $asset): RedirectResponse public function destroy(Asset $asset): RedirectResponse
{ {
CancelCheckoutRequest::run($asset, auth()->user()); try {
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.canceled')); CancelCheckoutRequest::run($asset, auth()->user());
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.canceled'));
} catch (\Exception $e) {
report($e);
return redirect()->back()->with('error', 'something bad happened');
}
} }