Addresses now a collection

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

View File

@ -206,10 +206,9 @@ class Account extends Model implements IDs
/**
* Get the address for the account
*
* @return array
* @todo Change this to return a collection
* @return Collection
*/
public function getAddressAttribute(): array
public function getAddressAttribute(): Collection
{
return collect([
'address1' => $this->address1,
@ -219,9 +218,7 @@ class Account extends Model implements IDs
$this->state,
$this->zip)
])
->filter()
->values()
->toArray();
->filter();
}
/**

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();
}
/**

View File

@ -34,22 +34,20 @@
<!-- info row -->
<div class="row invoice-info">
<div class="col-4 invoice-col">
FROM:
<address>
<strong>{{ $site->site_name }}</strong><br>
{!! join('<br>',$site->address) !!}
<br>
FROM: <strong>{{ $site->site_name }}</strong><br>
{!! $site->address->join('<br>') !!}
<br><br>
<strong>Email:</strong> {{ $site->site_email }}<br>
<strong>Phone:</strong> {{ $site->site_phone }}
</address>
</div>
<div class="col-4 invoice-col">
TO:
<address>
<strong>{{ $o->account->company }}</strong><br>
{!! join('<br>',$o->account->address) !!}
<br>
TO: <strong>{{ $o->account->company }}</strong><br>
{!! $o->account->address->join('<br>') !!}
<br><br>
<strong>Email:</strong> {{ $o->account->user->email }}<br>
@if ($o->account->phone)
<strong>Phone:</strong> {{ $o->account->phone }}<br>

View File

@ -23,7 +23,7 @@
@component('mail::footer')
<div class="fixedw" style="text-align: right; font-size: 0.8em;">
{{ config('mail.from.name') }}<br>
{!! join('<br>',$site->address) !!}<br>
{!! $site->address->join('<br>') !!}<br>
{{ $site->site_email }}
</div>
@endcomponent

View File

@ -26,7 +26,7 @@
<h2 style="text-align: right;">Our Contact Details</h2>
<address class="margin-bottom-40" style="float: right;">
<table>
<tr><th style="vertical-align:top; padding-right: 5px;">Address</th><td>{!! join('<br>',$site->address) !!}</td></tr>
<tr><th style="vertical-align:top; padding-right: 5px;">Address</th><td>{!! $site->address->join('<br>') !!}</td></tr>
@isset($site->site_fax)
<tr><th>Fax</th><td>{{ $site->site_fax }}</tr>
@endif