Invoice.php 769 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Models;
  3. # use Illuminate\Database\Eloquent\Model;
  4. class Invoice extends Model
  5. {
  6. protected $table = 'invoice';
  7. public function displayName() {
  8. return '$' . $this->amount .
  9. ($this->description ? ' | ' . substr($this->description, 0, 15) : '') .
  10. ' | ' . friendly_date_time($this->created_at);
  11. }
  12. public function customer() {
  13. return $this->hasOne(Customer::class, 'id', 'customer_id');
  14. }
  15. public function invoiceTransactions() {
  16. return $this->hasMany(InvoiceTransaction::class, 'invoice_id', 'id')->orderBy('created_at', 'ASC');
  17. }
  18. public function getPayUrl(){
  19. $detailJson = json_decode($this->detail_json ?? '{}', true);
  20. return @$detailJson['payUrl'];
  21. }
  22. }