diff --git a/app/Providers/Macro.php b/app/Providers/Macro.php index 10103900d..74bc2773c 100644 --- a/app/Providers/Macro.php +++ b/app/Providers/Macro.php @@ -4,6 +4,7 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; +use Illuminate\View\Factory as ViewFactory; class Macro extends ServiceProvider { @@ -26,6 +27,15 @@ class Macro extends ServiceProvider return $string; }); + + ViewFactory::macro('hasStack', function (...$sections) { + foreach ($sections as $section) { + if (isset($this->pushes[$section]) || isset($this->prepends[$section])) { + return true; + } + } + return false; + }); } /** diff --git a/resources/views/sales/invoices/show.blade.php b/resources/views/sales/invoices/show.blade.php index 0d401e883..c96c48deb 100644 --- a/resources/views/sales/invoices/show.blade.php +++ b/resources/views/sales/invoices/show.blade.php @@ -216,25 +216,27 @@ {{ setting('company.name') }} - - - {!! nl2br(setting('company.address')) !!} - - - - - @if (setting('company.tax_number')) + @if (setting('company.address')) + + + {!! nl2br(setting('company.address')) !!} + + + @endif + @if (setting('company.tax_number')) + + {{ trans('general.tax_number') }}: {{ setting('company.tax_number') }} - @endif - - - - - @if (setting('company.phone')) + + + @endif + @if (setting('company.phone')) + + {{ setting('company.phone') }} - @endif - - + + + @endif {{ setting('company.email') }} @@ -261,38 +263,50 @@ @stack('name_input_end') - - - @stack('address_input_start') - {!! nl2br($invoice->contact_address) !!} - @stack('address_input_end') - - - - - @stack('tax_number_input_start') - @if ($invoice->contact_tax_number) - {{ trans('general.tax_number') }}: {{ $invoice->contact_tax_number }} - @endif - @stack('tax_number_input_end') - - - - - @stack('phone_input_start') - @if ($invoice->contact_phone) - {{ $invoice->contact_phone }} - @endif - @stack('phone_input_end') - - - - - @stack('email_start') - {{ $invoice->contact_email }} - @stack('email_input_end') - - + @if ($invoice->contact_address || $__env->hasStack('address_input_start', 'address_input_end')) + + + @stack('address_input_start') + @if ($invoice->contact_address) + {!! nl2br($invoice->contact_address) !!} + @endif + @stack('address_input_end') + + + @endif + @if ($invoice->contact_tax_number || $__env->hasStack('tax_number_input_start', 'tax_number_input_end')) + + + @stack('tax_number_input_start') + @if ($invoice->contact_tax_number) + {{ trans('general.tax_number') }}: {{ $invoice->contact_tax_number }} + @endif + @stack('tax_number_input_end') + + + @endif + @if ($invoice->contact_phone || $__env->hasStack('phone_input_start', 'phone_input_end')) + + + @stack('phone_input_start') + @if ($invoice->contact_phone) + {{ $invoice->contact_phone }} + @endif + @stack('phone_input_end') + + + @endif + @if ($invoice->contact_email || $__env->hasStack('email_start', 'email_input_end')) + + + @stack('email_start') + @if ($invoice->contact_email) + {{ $invoice->contact_email }} + @endif + @stack('email_input_end') + + + @endif