1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Models;
- # use Illuminate\Database\Eloquent\Model;
- class Invoice extends Model
- {
- protected $table = 'invoice';
- public function displayName() {
- return '$' . $this->amount .
- ($this->description ? ' | ' . substr($this->description, 0, 15) : '') .
- ' | ' . friendly_date_time($this->created_at);
- }
- public function customer() {
- return $this->hasOne(Customer::class, 'id', 'customer_id');
- }
- public function invoiceTransactions() {
- return $this->hasMany(InvoiceTransaction::class, 'invoice_id', 'id')->orderBy('created_at', 'ASC');
- }
- public function getPayUrl(){
- $detailJson = json_decode($this->detail_json ?? '{}', true);
- return @$detailJson['payUrl'];
- }
- }
|