A free open source IT asset/license management system
Added payload to accessories API
snipebf5668a42e8e
diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.phpindex 90486b40f2..7933b19057 100644--- a/app/Http/Controllers/Api/AccessoriesController.php+++ b/app/Http/Controllers/Api/AccessoriesController.php@@ -288,32 +288,42 @@ class AccessoriesController extends Controller'note' => $request->input('note'),]);+$accessory_checkout->created_by = auth()->id();$accessory_checkout->save();++ $payload = [+ 'accessory_id' => $accessory->id,+ 'assigned_to' => $target->id,+ 'assigned_type' => $target::class,+ 'note' => $request->input('note'),+ 'created_by' => auth()->id(),+ 'pivot' => $accessory_checkout->id,+ ];}// Set this value to be able to pass the qty through to the eventevent(new CheckoutableCheckedOut($accessory, $target, auth()->user(), $request->input('note')));- return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/accessories/message.checkout.success')));+ return response()->json(Helper::formatStandardApiResponse('success', $payload, trans('admin/accessories/message.checkout.success')));}/*** Check in the item so that it can be checked out again to someone else*- * @uses Accessory::checkin_email() to determine if an email can and should be sent- * @author [A. Gianotto] [<[email protected]>]* @param Request $request* @param int $accessoryUserId* @param string $backto- * @return \Illuminate\Http\RedirectResponse+ * @return JsonResponse+ * @uses Accessory::checkin_email() to determine if an email can and should be sent+ * @author [A. Gianotto] [<[email protected]>]* @internal param int $accessoryId*/public function checkin(Request $request, $accessoryUserId = null){if (is_null($accessory_checkout = AccessoryCheckout::find($accessoryUserId))) {- return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist')));+ return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist', ['id' => $accessoryUserId])));}$accessory = Accessory::find($accessory_checkout->accessory_id);@@ -327,7 +337,14 @@ class AccessoriesController extends Controller$user = User::find($accessory_checkout->assigned_to);}- return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/accessories/message.checkin.success')));+ $payload = [+ 'accessory_id' => $accessory->id,+ 'note' => $request->input('note'),+ 'created_by' => auth()->id(),+ 'pivot' => $accessory_checkout->id,+ ];++ return response()->json(Helper::formatStandardApiResponse('success', $payload, trans('admin/accessories/message.checkin.success')));}return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.checkin.error')));