Service paid_to can be null if no invoices created yet

This commit is contained in:
Deon George 2022-09-29 18:06:16 +10:00
parent 319fa32754
commit b065d15f60
1 changed files with 5 additions and 2 deletions

View File

@ -826,10 +826,13 @@ class Service extends Model implements IDs
/**
* Work out when this service has been paid to.
*
* @return Carbon
* @return Carbon|null
*/
public function getPaidToAttribute(): Carbon
public function getPaidToAttribute(): ?Carbon
{
if (! $this->invoices->count())
return NULL;
foreach ($this->invoices->reverse() as $o)
if ($o->due == 0)
break;