Addresses now a collection

This commit is contained in:
2024-07-07 15:14:55 +10:00
parent 0d9dbafcf1
commit 76889728cd
5 changed files with 23 additions and 23 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
/**
@@ -68,15 +69,19 @@ class Site extends Model
/**
* Return the site address as an array
*
* @return array
* @return Collection
*/
public function getAddressAttribute(): array
public function getAddressAttribute(): Collection
{
return array_filter([
$this->site_address1,
$this->site_address2,
sprintf('%s %s %s',$this->site_city.(($this->site_state OR $this->site_postcode) ? ',' : ''),$this->site_state,$this->site_postcode)
]);
return collect([
'address1' => $this->site_address1,
'address2' => $this->site_address2,
'location' => sprintf('%s %s %s',
$this->site_city.(($this->site_state || $this->site_postcode) ? ',' : ''),
$this->site_state,
$this->site_postcode)
])
->filter();
}
/**