From 4b9b1c3fc217db4d1d1ad64cd41157abeb578fe1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 7 Feb 2023 22:47:43 +1100 Subject: [PATCH] Add Product Image and Product Max Quantity to the products table --- app/Http/Livewire/BillingPortalPurchasev2.php | 1 + app/Models/Product.php | 2 ++ app/Transformers/ProductTransformer.php | 2 ++ ...7_114011_add_additional_product_fields.php | 31 +++++++++++++++++++ .../billing-portal-purchasev2.blade.php | 26 ++++++++-------- 5 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 database/migrations/2023_02_07_114011_add_additional_product_fields.php diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index 099e7f8c4f04..f7f4d1ba79dc 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -322,6 +322,7 @@ class BillingPortalPurchasev2 extends Component 'total' => $total, 'qty' => $qty, 'is_recurring' => true, + 'product_image' => $p->product_image, ]); } diff --git a/app/Models/Product.php b/app/Models/Product.php index bf8847db8804..34f9fee8014a 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -39,6 +39,8 @@ class Product extends BaseModel 'in_stock_quantity', 'stock_notification_threshold', 'stock_notification', + 'max_quantity', + 'product_image', ]; protected $touches = []; diff --git a/app/Transformers/ProductTransformer.php b/app/Transformers/ProductTransformer.php index 12fa8ddf9aa8..3d0247da0002 100644 --- a/app/Transformers/ProductTransformer.php +++ b/app/Transformers/ProductTransformer.php @@ -93,6 +93,8 @@ class ProductTransformer extends EntityTransformer 'in_stock_quantity' => (int) $product->in_stock_quantity ?: 0, 'stock_notification' => (bool) $product->stock_notification, 'stock_notification_threshold' => (int) $product->stock_notification_threshold, + 'max_quantity' => (int) $product->max_quantity, + 'product_image' => (string) $product->product_image ?: '', ]; } } diff --git a/database/migrations/2023_02_07_114011_add_additional_product_fields.php b/database/migrations/2023_02_07_114011_add_additional_product_fields.php new file mode 100644 index 000000000000..4b0760722b42 --- /dev/null +++ b/database/migrations/2023_02_07_114011_add_additional_product_fields.php @@ -0,0 +1,31 @@ +unsignedInteger("max_quantity")->nullable(); + $table->string("product_image", 191)->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}; diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php index b5398e952937..2adb5cfcf1e4 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php @@ -36,9 +36,9 @@ @if(!empty($subscription->recurring_product_ids)) @foreach($recurring_products as $index => $product)
  • - @if(filter_var($product->custom_value1, FILTER_VALIDATE_URL)) + @if(filter_var($product->product_image, FILTER_VALIDATE_URL))
    - +
    @endif
    @@ -74,7 +74,7 @@ @endfor } @else - @for ($i = 2; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, max(100,$product->custom_value2)) : max(100,$product->custom_value2)); $i++) + @for ($i = 2; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, max(100,$product->max_quantity)) : max(100,$product->max_quantity)); $i++) @endfor @endif @@ -96,9 +96,9 @@ @if(!empty($subscription->product_ids)) @foreach($products as $product)
  • - @if(filter_var($product->custom_value1, FILTER_VALIDATE_URL)) + @if(filter_var($product->product_image, FILTER_VALIDATE_URL))
    - +
    @endif
    @@ -135,9 +135,9 @@ @if(!empty($subscription->optional_recurring_product_ids)) @foreach($optional_recurring_products as $index => $product)
  • - @if(filter_var($product->custom_value1, FILTER_VALIDATE_URL)) + @if(filter_var($product->product_image, FILTER_VALIDATE_URL))
    - +
    @endif
    @@ -148,7 +148,7 @@
    - @if(is_numeric($product->custom_value2)) + @if(is_numeric($product->max_quantity))

    @if($subscription->use_inventory_management && $product->in_stock_quantity == 0) @@ -162,7 +162,7 @@ @endif > - @for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, max(100,$product->custom_value2)) : max(100,$product->custom_value2)); $i++) + @for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, max(100,$product->max_quantity)) : max(100,$product->max_quantity)); $i++) @endfor @@ -176,9 +176,9 @@ @if(!empty($subscription->optional_product_ids)) @foreach($optional_products as $index => $product)
  • - @if(filter_var($product->custom_value1, FILTER_VALIDATE_URL)) + @if(filter_var($product->product_image, FILTER_VALIDATE_URL))
    - +
    @endif
    @@ -190,7 +190,7 @@

    - @if(is_numeric($product->custom_value2)) + @if(is_numeric($product->max_quantity))

    @if($subscription->use_inventory_management && $product->in_stock_quantity == 0) @@ -200,7 +200,7 @@ @endif