Skip to content

Commit 27b1bc3

Browse files
author
Babichev Maxim
committed
update method canBuy, add Customer
1 parent 5402d2d commit 27b1bc3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Interfaces/Product.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ interface Product extends Wallet
66
{
77

88
/**
9+
* @param Customer $customer
10+
*
911
* @return bool
1012
*/
11-
public function canBuy(): bool;
13+
public function canBuy(Customer $customer): bool;
1214

1315
/**
1416
* @return int

src/Traits/CanBePaid.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Bavix\Wallet\Models\Transfer;
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Database\Eloquent\ModelNotFoundException;
10-
use Illuminate\Database\Eloquent\Relations\MorphMany;
1110
use Illuminate\Support\Facades\DB;
1211

1312
trait CanBePaid
@@ -22,7 +21,7 @@ trait CanBePaid
2221
*/
2322
public function pay(Product $product): Transfer
2423
{
25-
if (!$product->canBuy()) {
24+
if (!$product->canBuy($this)) {
2625
throw new ProductEnded('The product is out of stock');
2726
}
2827

0 commit comments

Comments
 (0)