Add withData() to PaymentHash

This commit is contained in:
Benjamin Beganović 2021-07-26 17:03:28 +02:00
parent 7dd7a6e4b1
commit 2501654fec

View File

@ -21,7 +21,6 @@ class PaymentHash extends Model
'data' => 'object', 'data' => 'object',
]; ];
public function invoices() public function invoices()
{ {
return $this->data->invoices; return $this->data->invoices;
@ -41,4 +40,12 @@ class PaymentHash extends Model
{ {
return $this->belongsTo(Invoice::class, 'fee_invoice_id', 'id'); return $this->belongsTo(Invoice::class, 'fee_invoice_id', 'id');
} }
public function withData(string $property, $value): PaymentHash
{
$this->data = array_merge((array) $this->data, [$property => $value]);
$this->save();
return $this;
}
} }