Skip to content

Commit

Permalink
Add declinedCheckout method to Accessory model
Browse files Browse the repository at this point in the history
  • Loading branch information
inietov committed Aug 14, 2023
1 parent 291fa1c commit 4796598
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/Models/Accessory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ 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

0 comments on commit 4796598

Please sign in to comment.