invoice_ids); if(count($invoices) >= 1) { foreach($invoices as $invoice){ if(is_string($invoice) && strlen($invoice) > 1) $collection->push($this->decodePrimaryKey($invoice)); } } return $collection; } public function getEntityType() { return self::class; } public function company() { return $this->belongsTo(Company::class); } public function vendor() { return $this->belongsTo(Vendor::class); } public function expense() { return $this->belongsTo(Expense::class); } public function user() { return $this->belongsTo(User::class)->withTrashed(); } public function bank_integration() { return $this->belongsTo(BankIntegration::class)->withTrashed(); } public function account() { return $this->belongsTo(Account::class)->withTrashed(); } public function matchInvoiceNumber() { if(strlen($this->description) > 1) { $i = Invoice::where('company_id', $this->company_id) ->whereIn('status_id', [1,2,3]) ->where('is_deleted', 0) ->where('number', 'LIKE', '%'.$this->description.'%') ->first(); return $i ?: false; } return false; } }