Skip to content

Commit

Permalink
Move the declinedCheckout function so it don/'t separate the class pr…
Browse files Browse the repository at this point in the history
…operties
  • Loading branch information
inietov committed Aug 14, 2023
1 parent 8da2a8a commit 9644083
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions app/Models/Accessory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 9644083

Please sign in to comment.