@@ -288,32 +288,42 @@ public function checkout(AccessoryCheckoutRequest $request, Accessory $accessory
288288 'note ' => $ request ->input ('note ' ),
289289 ]);
290290
291+
291292 $ accessory_checkout ->created_by = auth ()->id ();
292293 $ accessory_checkout ->save ();
294+
295+ $ payload = [
296+ 'accessory_id ' => $ accessory ->id ,
297+ 'assigned_to ' => $ target ->id ,
298+ 'assigned_type ' => $ target ::class,
299+ 'note ' => $ request ->input ('note ' ),
300+ 'created_by ' => auth ()->id (),
301+ 'pivot ' => $ accessory_checkout ->id ,
302+ ];
293303 }
294304
295305 // Set this value to be able to pass the qty through to the event
296306 event (new CheckoutableCheckedOut ($ accessory , $ target , auth ()->user (), $ request ->input ('note ' )));
297307
298- return response ()->json (Helper::formatStandardApiResponse ('success ' , null , trans ('admin/accessories/message.checkout.success ' )));
308+ return response ()->json (Helper::formatStandardApiResponse ('success ' , $ payload , trans ('admin/accessories/message.checkout.success ' )));
299309
300310 }
301311
302312 /**
303313 * Check in the item so that it can be checked out again to someone else
304314 *
305- * @uses Accessory::checkin_email() to determine if an email can and should be sent
306- * @author [A. Gianotto] [<[email protected] >] 307315 * @param Request $request
308316 * @param int $accessoryUserId
309317 * @param string $backto
310- * @return \Illuminate\Http\RedirectResponse
318+ * @return JsonResponse
319+ * @uses Accessory::checkin_email() to determine if an email can and should be sent
320+ * @author [A. Gianotto] [<[email protected] >] 311321 * @internal param int $accessoryId
312322 */
313323 public function checkin (Request $ request , $ accessoryUserId = null )
314324 {
315325 if (is_null ($ accessory_checkout = AccessoryCheckout::find ($ accessoryUserId ))) {
316- return response ()->json (Helper::formatStandardApiResponse ('error ' , null , trans ('admin/accessories/message.does_not_exist ' )));
326+ return response ()->json (Helper::formatStandardApiResponse ('error ' , null , trans ('admin/accessories/message.does_not_exist ' , [ ' id ' => $ accessoryUserId ] )));
317327 }
318328
319329 $ accessory = Accessory::find ($ accessory_checkout ->accessory_id );
@@ -327,7 +337,14 @@ public function checkin(Request $request, $accessoryUserId = null)
327337 $ user = User::find ($ accessory_checkout ->assigned_to );
328338 }
329339
330- return response ()->json (Helper::formatStandardApiResponse ('success ' , null , trans ('admin/accessories/message.checkin.success ' )));
340+ $ payload = [
341+ 'accessory_id ' => $ accessory ->id ,
342+ 'note ' => $ request ->input ('note ' ),
343+ 'created_by ' => auth ()->id (),
344+ 'pivot ' => $ accessory_checkout ->id ,
345+ ];
346+
347+ return response ()->json (Helper::formatStandardApiResponse ('success ' , $ payload , trans ('admin/accessories/message.checkin.success ' )));
331348 }
332349
333350 return response ()->json (Helper::formatStandardApiResponse ('error ' , null , trans ('admin/accessories/message.checkin.error ' )));
0 commit comments