From 96440834bd1e354f126d94c4c4e4b40ffbf250d8 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 14 Aug 2023 16:16:28 -0600 Subject: [PATCH] Move the declinedCheckout function so it don/'t separate the class properties --- app/Models/Accessory.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php index e1da483b979e..86502dc7e7bf 100755 --- a/app/Models/Accessory.php +++ b/app/Models/Accessory.php @@ -32,16 +32,6 @@ class Accessory extends SnipeModel use Searchable; use Acceptable; - - public function declinedCheckout(User $declinedBy, $signature) - { - if (is_null($accessory_user = \DB::table('accessories_users')->where('assigned_to', $declinedBy->id)->where('accessory_id', $this->id)->latest('created_at'))) { - // Redirect to the accessory management page with error - return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); - } - - $accessory_user->limit(1)->delete(); - } /** * The attributes that should be included when searching the model. @@ -359,6 +349,22 @@ public function numRemaining() return (int) $remaining; } + /** + * Run after the checkout acceptance was declined by the user + * + * @param User $acceptedBy + * @param string $signature + */ + public function declinedCheckout(User $declinedBy, $signature) + { + if (is_null($accessory_user = \DB::table('accessories_users')->where('assigned_to', $declinedBy->id)->where('accessory_id', $this->id)->latest('created_at'))) { + // Redirect to the accessory management page with error + return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); + } + + $accessory_user->limit(1)->delete(); + } + /** * Query builder scope to order on company *