From d96924bc65314c32e4b91aceb5f3f39823e09c5e Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 7 Jul 2024 15:14:55 +1000 Subject: [PATCH] Addresses now a collection --- app/Models/Account.php | 9 +++------ app/Models/Site.php | 19 ++++++++++++------- .../backend/adminlte/invoice/view.blade.php | 14 ++++++-------- .../views/vendor/mail/html/message.blade.php | 2 +- .../layouts/partials/footer.blade.php | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 9513448..df71a29 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -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(); } /** diff --git a/app/Models/Site.php b/app/Models/Site.php index 663b571..360e3ea 100644 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -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(); } /** diff --git a/resources/views/theme/backend/adminlte/invoice/view.blade.php b/resources/views/theme/backend/adminlte/invoice/view.blade.php index 1446fac..05f0a22 100644 --- a/resources/views/theme/backend/adminlte/invoice/view.blade.php +++ b/resources/views/theme/backend/adminlte/invoice/view.blade.php @@ -34,22 +34,20 @@
- FROM:
- {{ $site->site_name }}
- {!! join('
',$site->address) !!} -
+ FROM: {{ $site->site_name }}
+ {!! $site->address->join('
') !!} +

Email: {{ $site->site_email }}
Phone: {{ $site->site_phone }}
- TO:
- {{ $o->account->company }}
- {!! join('
',$o->account->address) !!} -
+ TO: {{ $o->account->company }}
+ {!! $o->account->address->join('
') !!} +

Email: {{ $o->account->user->email }}
@if ($o->account->phone) Phone: {{ $o->account->phone }}
diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php index 2a11238..6a2806f 100644 --- a/resources/views/vendor/mail/html/message.blade.php +++ b/resources/views/vendor/mail/html/message.blade.php @@ -23,7 +23,7 @@ @component('mail::footer')
{{ config('mail.from.name') }}
-{!! join('
',$site->address) !!}
+{!! $site->address->join('
') !!}
{{ $site->site_email }}
@endcomponent diff --git a/resources/views/vendor/metronic/layouts/partials/footer.blade.php b/resources/views/vendor/metronic/layouts/partials/footer.blade.php index f2ed1bf..2018f9e 100644 --- a/resources/views/vendor/metronic/layouts/partials/footer.blade.php +++ b/resources/views/vendor/metronic/layouts/partials/footer.blade.php @@ -26,7 +26,7 @@

Our Contact Details

- + @isset($site->site_fax) @endif
Address{!! join('
',$site->address) !!}
Address{!! $site->address->join('
') !!}
Fax{{ $site->site_fax }}