Fix a problem where voucherify campaign vouchers limit not displaying with correct info for the month

This commit is contained in:
Dillon Ngo
2024-08-04 03:22:53 +08:00
parent bdf0a3afeb
commit 8973e7b50f
7 changed files with 8 additions and 8 deletions
@@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
interface KeyValueInterface
{
public function attributes(): morphMany;
public function attributesKVP(): morphMany;
}
@@ -22,7 +22,7 @@ class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
$model->key = $object->getKey();
$model->value = $object->getValue();
return $this->handler($kv->attributes(), $model);
return $this->handler($kv->attributesKVP(), $model);
}
}
@@ -193,7 +193,7 @@ class CreateVoucherLogic extends AbstractControllerLogic
$key,
$total
);
$metadata = $voucherCampaign->attributes()->where('key', $key)->first();
$metadata = $voucherCampaign->attributesKVP()->where('key', $key)->first();
if($metadata){
$this->updatesKeyValuePair->execute($metadata, $keyValuePairObject);
}
+1 -1
View File
@@ -17,7 +17,7 @@ class UserRewardResource extends JsonResource
{
$emailReminder = null;
if ($request->has('isAdmin')) {
$keyValuePairs = $this->user->attributes()->get();
$keyValuePairs = $this->user->attributesKVP()->get();
$emailReminder = KeyValueBasicResource::collection($keyValuePairs);
$this->voucher->email = $emailReminder;
}
@@ -17,7 +17,7 @@ class VoucherCampaignResource extends JsonResource
{
$metadata = null;
if ($request->has('include_metadata')) {
$metadata = KeyValueBasicResource::collection($this->attributes);
$metadata = KeyValueBasicResource::collection($this->attributesKVP()->latest()->get());
}
return [
+2 -2
View File
@@ -106,7 +106,7 @@ class User extends AbstractModel implements
public function hasAttribute(string $key, $value = null): bool
{
$query = $this->attributes()->where('key', $key);
$query = $this->attributesKVP()->where('key', $key);
if ($value !== null) {
$query->where('value', $value);
@@ -116,7 +116,7 @@ class User extends AbstractModel implements
}
public function attributes(): MorphMany
public function attributesKVP(): MorphMany
{
return $this->morphMany(KeyValuePair::class, 'owner');
}
+1 -1
View File
@@ -22,7 +22,7 @@ class VoucherCampaign extends AbstractModel implements KeyValueInterface
/**
* @return MorphMany
*/
public function attributes(): MorphMany
public function attributesKVP(): MorphMany
{
return $this->morphMany(KeyValuePair::class, 'owner');
}