mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Voucherify data patch for development environment only
This commit is contained in:
@@ -16,8 +16,32 @@ class UpdateVoucherCampaignsTable extends Migration
|
||||
DB::table('voucher_campaigns')->where('id', 1)->update(['campaign_id' => 'camp_snxv2JQlh5v9LEDBbIBOnibD']);
|
||||
DB::table('voucher_campaigns')->where('id', 2)->update(['campaign_id' => 'camp_lEM7WhLHFlhcRKRR0C4bXH0F']);
|
||||
DB::table('voucher_campaigns')->where('id', 3)->update(['campaign_id' => 'camp_JP9qBGBYEinVjzAE1vjynMe0']);
|
||||
|
||||
$voucherCampaignIds = [1, 2, 3];
|
||||
foreach ($voucherCampaignIds as $id) {
|
||||
$campaignId = DB::table('voucher_campaigns')->where('id', $id)->value('campaign_id');
|
||||
$ownerId = DB::table('voucher_campaigns')->where('id', $id)->value('id');
|
||||
$upperCampaignId = strtoupper($campaignId);
|
||||
|
||||
$keysToUpdate = DB::table('key_value_pairs')
|
||||
->where('key', 'like', '%_TOTAL%')
|
||||
->where('owner_type', 'App\Models\VoucherCampaign')
|
||||
->where('owner_id', (int) $ownerId)
|
||||
->get();
|
||||
|
||||
foreach ($keysToUpdate as $entry) {
|
||||
$parts = explode('_', $entry->key);
|
||||
$lastTwoParts = array_slice($parts, -2); // Get the last two elements
|
||||
$newKey = "{$upperCampaignId}_" . implode('_', $lastTwoParts);
|
||||
|
||||
DB::table('key_value_pairs')
|
||||
->where('id', $entry->id)
|
||||
->update(['key' => $newKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
|
||||
Reference in New Issue
Block a user