Skip to content

Commit

Permalink
[0.2] Hotfix - fix pluck on null (lunarphp#834)
Browse files Browse the repository at this point in the history
* fix pluck on null

* Update AbstractDiscount.php

---------

Co-authored-by: Alec Ritson <hello@itsalec.co.uk>
  • Loading branch information
wychoong and alecritson authored Feb 10, 2023
1 parent 7b5ce85 commit 51af420
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ public function mount()
return $this->mapProductToArray($limitation->purchasable);
});

$this->selectedBrands = $this->discount->brands->map(fn ($brand) => $this->mapBrandToArray($brand)) ?? collect();
$this->selectedCollections = $this->discount->collections->map(fn ($collection) => $this->mapCollectionToArray($collection)) ?? collect();

$this->selectedConditions = $this->discount->purchasableConditions()
->wherePurchasableType(Product::class)
->pluck('purchasable_id')->values()->toArray();
Expand Down Expand Up @@ -329,7 +326,7 @@ public function removeProduct($index)
*/
public function save()
{
$redirect = ! $this->discount->id;
$redirect = !$this->discount->id;

$this->withValidator(function (Validator $validator) {
$validator->after(function ($validator) {
Expand All @@ -353,8 +350,8 @@ public function save()
$channels = collect($this->availability['channels'])->mapWithKeys(function ($channel) {
return [
$channel['channel_id'] => [
'starts_at' => ! $channel['enabled'] ? null : $channel['starts_at'],
'ends_at' => ! $channel['enabled'] ? null : $channel['ends_at'],
'starts_at' => !$channel['enabled'] ? null : $channel['starts_at'],
'ends_at' => !$channel['enabled'] ? null : $channel['ends_at'],
'enabled' => $channel['enabled'],
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function mount()

$this->selectedBrands = collect();
$this->selectedCollections = collect();
$this->selectedProducts = collect();
}

/**
Expand Down

0 comments on commit 51af420

Please sign in to comment.