From f9d6e8b0cccc1b93e2793e8c2b074185a30c3994 Mon Sep 17 00:00:00 2001 From: Sebastian Cretu Date: Wed, 3 Mar 2021 17:09:05 +0100 Subject: [PATCH] fix(items): added unit name after quantity in the pdf templates --- app/Models/EstimateItem.php | 3 +- app/Models/InvoiceItem.php | 3 +- ...2021_03_03_155223_add_unit_name_to_pdf.php | 38 +++++++++++++++++++ .../app/pdf/estimate/partials/table.blade.php | 2 +- .../app/pdf/invoice/partials/table.blade.php | 2 +- 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2021_03_03_155223_add_unit_name_to_pdf.php diff --git a/app/Models/EstimateItem.php b/app/Models/EstimateItem.php index 74373545..eb0755a1 100644 --- a/app/Models/EstimateItem.php +++ b/app/Models/EstimateItem.php @@ -22,7 +22,8 @@ class EstimateItem extends Model 'discount_val', 'tax', 'total', - 'discount' + 'discount', + 'unit_name', ]; protected $casts = [ diff --git a/app/Models/InvoiceItem.php b/app/Models/InvoiceItem.php index b024708b..a8eb445d 100644 --- a/app/Models/InvoiceItem.php +++ b/app/Models/InvoiceItem.php @@ -25,7 +25,8 @@ class InvoiceItem extends Model 'discount_val', 'total', 'tax', - 'discount' + 'discount', + 'unit_name', ]; protected $casts = [ diff --git a/database/migrations/2021_03_03_155223_add_unit_name_to_pdf.php b/database/migrations/2021_03_03_155223_add_unit_name_to_pdf.php new file mode 100644 index 00000000..9f17aefc --- /dev/null +++ b/database/migrations/2021_03_03_155223_add_unit_name_to_pdf.php @@ -0,0 +1,38 @@ +string('unit_name')->nullable()->after('quantity'); + }); + Schema::table('estimate_items', function (Blueprint $table) { + $table->string('unit_name')->nullable()->after('quantity'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoice_items', function (Blueprint $table) { + $table->dropColumn('unit_name'); + }); + Schema::table('estimate_items', function (Blueprint $table) { + $table->dropColumn('unit_name'); + }); + } +} diff --git a/resources/views/app/pdf/estimate/partials/table.blade.php b/resources/views/app/pdf/estimate/partials/table.blade.php index 0a01e34d..288c68d0 100644 --- a/resources/views/app/pdf/estimate/partials/table.blade.php +++ b/resources/views/app/pdf/estimate/partials/table.blade.php @@ -34,7 +34,7 @@ class="pr-20 text-right item-cell" style="vertical-align: top;" > - {{$item->quantity}} + {{$item->quantity}} @if($item->unit_name) {{$item->unit_name}} @endif - {{$item->quantity}} + {{$item->quantity}} @if($item->unit_name) {{$item->unit_name}} @endif