2020-08-25 23:06:38 +10:00
|
|
|
<?php
|
|
|
|
|
/**
|
2020-09-06 19:38:10 +10:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-08-25 23:06:38 +10:00
|
|
|
*
|
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
|
*
|
2022-04-27 13:20:41 +10:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-08-25 23:06:38 +10:00
|
|
|
*
|
2021-06-16 16:58:16 +10:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-08-25 23:06:38 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class PaymentHash extends Model
|
|
|
|
|
{
|
2020-09-06 19:38:10 +10:00
|
|
|
protected $guarded = ['id'];
|
2020-08-30 22:00:19 +10:00
|
|
|
|
2020-08-25 23:06:38 +10:00
|
|
|
protected $casts = [
|
2020-09-06 19:38:10 +10:00
|
|
|
'data' => 'object',
|
2020-08-25 23:06:38 +10:00
|
|
|
];
|
2022-06-21 09:57:17 +00:00
|
|
|
|
2020-08-25 23:06:38 +10:00
|
|
|
public function invoices()
|
|
|
|
|
{
|
2020-10-22 15:24:18 +02:00
|
|
|
return $this->data->invoices;
|
2020-08-25 23:06:38 +10:00
|
|
|
}
|
2020-10-13 23:28:30 +11:00
|
|
|
|
2021-01-06 16:54:04 +11:00
|
|
|
public function credits_total()
|
|
|
|
|
{
|
|
|
|
|
return isset($this->data->credits) ? $this->data->credits : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-13 23:28:30 +11:00
|
|
|
public function payment()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Payment::class)->withTrashed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function fee_invoice()
|
|
|
|
|
{
|
2022-03-05 09:21:17 +11:00
|
|
|
return $this->belongsTo(Invoice::class, 'fee_invoice_id', 'id')->withTrashed();
|
2020-10-13 23:28:30 +11:00
|
|
|
}
|
2021-07-26 17:03:28 +02:00
|
|
|
|
2021-07-29 15:13:38 +02:00
|
|
|
public function withData(string $property, $value): self
|
2021-07-26 17:03:28 +02:00
|
|
|
{
|
|
|
|
|
$this->data = array_merge((array) $this->data, [$property => $value]);
|
|
|
|
|
$this->save();
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2020-08-25 23:06:38 +10:00
|
|
|
}
|