fix: 🐛 add property_exists in getCustomerDiscountsCount
This commit is contained in:
parent
427ee27f63
commit
7459d9450b
1 changed files with 11 additions and 5 deletions
|
|
@ -162,16 +162,22 @@ class Discount extends Model
|
|||
/** @var \LDC\MESBR\MesBr */
|
||||
$mesBr = app('mesBrAPI');
|
||||
$customerWall = $mesBr->getMurCustomer($hashcode);
|
||||
|
||||
if ($customerWall->status === "KO") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isset($mesBr->getMurCustomer($hashcode)->coupons)) {
|
||||
return collect($mesBr->getMurCustomer($hashcode)->coupons)->filter(function ($discount) {
|
||||
return !$discount->used;
|
||||
})->count();
|
||||
if (!property_exists($customerWall, 'coupons')) {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
if (!isset($customerWall->coupons)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return collect($customerWall->coupons)
|
||||
->filter(fn($discount) => !$discount->used)
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue