mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 05:23:58 +00:00
Merge branch 'dillon/63.3-sorry-voucher-debug' into 'master'
Fix a problem where voucherify campaign vouchers limit not displaying with... See merge request CIEFWorldwideSdnBhd/exchange-2.0!169
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
+13
@@ -2,6 +2,7 @@
|
||||
<div class="row bg-white padding-10 m-b-10 rounded">
|
||||
<div class="col-2 fs-12">{{data.name}}</div>
|
||||
<div class="col-1 text-success text-center">{{data.metadata && data.metadata.length > 0 ? data.metadata[0].value : 0 }}</div>
|
||||
<div class="col-1 text-success text-center">{{data.metadata && data.metadata.length > 0 ? extractMonth(data.metadata[0].key) : '' }}</div>
|
||||
<div class="col-1 text-center">{{data.limit_per_month}}</div>
|
||||
<div class="col-3 fs-12">{{data.campaign_id}}</div>
|
||||
</div>
|
||||
@@ -17,6 +18,18 @@
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
extractMonth(inputString) {
|
||||
const firstUnderscoreIndex = inputString.indexOf('_');
|
||||
if (firstUnderscoreIndex === -1) return '';
|
||||
|
||||
const secondUnderscoreIndex = inputString.indexOf('_', firstUnderscoreIndex + 1);
|
||||
if (secondUnderscoreIndex === -1) return '';
|
||||
|
||||
const thirdUnderscoreIndex = inputString.indexOf('_', secondUnderscoreIndex + 1);
|
||||
if (thirdUnderscoreIndex === -1) return '';
|
||||
|
||||
return inputString.substring(secondUnderscoreIndex + 1, thirdUnderscoreIndex);
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler],
|
||||
}
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@
|
||||
<div class="col">
|
||||
<div class="row padding-10">
|
||||
<div class="col-2 fs-10">Name</div>
|
||||
<div class="col-1 fs-10 text-center">Issued (this month)</div>
|
||||
<div class="col-1 fs-10 text-center">Issued</div>
|
||||
<div class="col-1 fs-10 text-center">Month</div>
|
||||
<div class="col-1 fs-10 text-center">Limit Per Month</div>
|
||||
<div class="col-3 fs-10">Campaign Id</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user