Fix some breaking changes that is already deployed to master branch

This commit is contained in:
Dillon Ngo
2024-08-07 06:56:49 +08:00
parent 6160ec0651
commit 32833064b3
4 changed files with 5 additions and 5 deletions
@@ -59,7 +59,7 @@ class UpdateBankMetadataLogic extends AbstractControllerLogic
$this->canUpdateBankMetadata->passes($bankMetadataObject);
$transaction = $this->fetchesTransaction->execute(['id' => $request->input('transactionId')]);
$transaction->attributes()->delete();
$transaction->attributesKVP()->delete();
return $this->response([]);
}
@@ -66,7 +66,7 @@ class UpdateBankProcessor
// if ($result->wasRecentlyCreated) {
//Key #1 for Bank
$kvp = $bank->attributes()->where('key', 'App\Models\Bank')->where('value', $result->id)->latest()->first();
$kvp = $bank->attributesKVP()->where('key', 'App\Models\Bank')->where('value', $result->id)->latest()->first();
if(!$kvp){
$keyValuePairObject = new KeyValuePairObject(
"App\Models\Bank",
+1 -1
View File
@@ -75,7 +75,7 @@ class Bank extends AbstractModel implements KeyValueInterface
/**
* @return MorphMany
*/
public function attributes(): MorphMany
public function attributesKVP(): MorphMany
{
return $this->morphMany(KeyValuePair::class, 'owner');
}
+2 -2
View File
@@ -272,7 +272,7 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
/**
* @return MorphMany
*/
public function attributes(): MorphMany
public function attributesKVP(): MorphMany
{
return $this->morphMany(KeyValuePair::class, 'owner');
}
@@ -283,7 +283,7 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
*/
public function getBankAttribute()
{
$keyValuePairs = $this->attributes()->where('key', 'App\Models\Bank')->latest()->first();
$keyValuePairs = $this->attributesKVP()->where('key', 'App\Models\Bank')->latest()->first();
if($keyValuePairs){
$bank = Bank::where('id', $keyValuePairs->value)->first();
return $bank;