Add Product Image and Product Max Quantity to the products table

This commit is contained in:
David Bomba 2023-02-07 22:47:43 +11:00
parent 6a62b5cbfa
commit 4b9b1c3fc2
5 changed files with 49 additions and 13 deletions

View File

@ -322,6 +322,7 @@ class BillingPortalPurchasev2 extends Component
'total' => $total,
'qty' => $qty,
'is_recurring' => true,
'product_image' => $p->product_image,
]);
}

View File

@ -39,6 +39,8 @@ class Product extends BaseModel
'in_stock_quantity',
'stock_notification_threshold',
'stock_notification',
'max_quantity',
'product_image',
];
protected $touches = [];

View File

@ -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 ?: '',
];
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table){
$table->unsignedInteger("max_quantity")->nullable();
$table->string("product_image", 191)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};

View File

@ -36,9 +36,9 @@
@if(!empty($subscription->recurring_product_ids))
@foreach($recurring_products as $index => $product)
<li class="flex py-6">
@if(filter_var($product->custom_value1, FILTER_VALIDATE_URL))
@if(filter_var($product->product_image, FILTER_VALIDATE_URL))
<div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2">
<img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center p-2">
<img src="{{$product->product_image}}" alt="" class="h-full w-full object-cover object-center p-2">
</div>
@endif
<div class="ml-0 flex flex-1 flex-col">
@ -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++)
<option value="{{$i}}">{{$i}}</option>
@endfor
@endif
@ -96,9 +96,9 @@
@if(!empty($subscription->product_ids))
@foreach($products as $product)
<li class="flex py-6">
@if(filter_var($product->custom_value1, FILTER_VALIDATE_URL))
@if(filter_var($product->product_image, FILTER_VALIDATE_URL))
<div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2">
<img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center p-2">
<img src="{{$product->product_image}}" alt="" class="h-full w-full object-cover object-center p-2">
</div>
@endif
<div class="ml-0 flex flex-1 flex-col">
@ -135,9 +135,9 @@
@if(!empty($subscription->optional_recurring_product_ids))
@foreach($optional_recurring_products as $index => $product)
<li class="flex py-6">
@if(filter_var($product->custom_value1, FILTER_VALIDATE_URL))
@if(filter_var($product->product_image, FILTER_VALIDATE_URL))
<div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2">
<img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center p-2">
<img src="{{$product->product_image}}" alt="" class="h-full w-full object-cover object-center p-2">
</div>
@endif
<div class="ml-0 flex flex-1 flex-col">
@ -148,7 +148,7 @@
</div>
</div>
<div class="flex justify-between text-sm mt-1">
@if(is_numeric($product->custom_value2))
@if(is_numeric($product->max_quantity))
<p class="text-gray-500 w-3/4"></p>
<div class="flex place-content-end">
@if($subscription->use_inventory_management && $product->in_stock_quantity == 0)
@ -162,7 +162,7 @@
@endif
>
<option value="0" selected="selected">0</option>
@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++)
<option value="{{$i}}">{{$i}}</option>
@endfor
</select>
@ -176,9 +176,9 @@
@if(!empty($subscription->optional_product_ids))
@foreach($optional_products as $index => $product)
<li class="flex py-6">
@if(filter_var($product->custom_value1, FILTER_VALIDATE_URL))
@if(filter_var($product->product_image, FILTER_VALIDATE_URL))
<div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2">
<img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center p-2">
<img src="{{$product->product_image}}" alt="" class="h-full w-full object-cover object-center p-2">
</div>
@endif
<div class="ml-0 flex flex-1 flex-col">
@ -190,7 +190,7 @@
<p class="mt-1 text-sm text-gray-500"></p>
</div>
<div class="flex justify-between text-sm mt-1">
@if(is_numeric($product->custom_value2))
@if(is_numeric($product->max_quantity))
<p class="text-gray-500 w-3/4"></p>
<div class="flex place-content-end">
@if($subscription->use_inventory_management && $product->in_stock_quantity == 0)
@ -200,7 +200,7 @@
@endif
<select wire:model.debounce.300ms="data.{{ $index }}.optional_qty" class="rounded-md border-gray-300 shadow-sm sm:text-sm">
<option value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, min(100,$product->custom_value2)) : min(100,$product->custom_value2)); $i++)
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, min(100,$product->max_quantity)) : min(100,$product->max_quantity)); $i++)
<option value="{{$i}}">{{$i}}</option>
@endfor
</select>