Skip to content

Commit cd28c9f

Browse files
committed
Add is_only_wholesale attribute to Product model and resource, and update migration
This commit introduces the 'is_only_wholesale' attribute to the Product model and the ProductResource, allowing for better differentiation of product types. The database migration is also updated to include this new attribute with a default value, enhancing the product data structure and management capabilities.
1 parent b2d8f60 commit cd28c9f

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

app/Http/Resources/ProductResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function toArray(Request $request): array
3737
"count_seller"=>OrderDetail::where("product_id",$this->id)->count(),
3838
"reviewCount"=>$this->reviews->count(),
3939
"product_url" => $this->product_url,
40+
"is_only_wholesale"=>$this->is_only_wholesale,
4041
"whatsapp_number"=>$this->whatsapp_number,
4142
"productWholeSales"=>WholeSalePriceResource::collection($this->wholesalePrices),
4243
"product_images" => ImageResource::collection($this->images),

app/Models/Product.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Product extends Model
2828
'product_price',
2929
'product_quantity',
3030
'is_wholesale',
31+
'is_only_wholesale'
3132
];
3233
protected $keyType = 'string';
3334
public $incrementing = false;

database/migrations/2024_11_26_191119_create_products_table.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ public function up(): void
2121
->constrained()
2222
->restrictOnDelete()
2323
->restrictOnUpdate();
24+
2425
$table->string('product_url')->nullable();
2526
$table->string('product_price')->nullable();
2627
$table->boolean('is_wholesale')->default(0);
28+
$table->boolean('is_only_wholesale')->default(0);
2729
$table->string('product_quantity')->nullable();
2830
$table->string('product_profile')->nullable();
2931
$table->boolean("status")->default(0);

routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
Route::post('/delivery/confirm/{id}', [ConfirmStatusDeliveryController::class, 'confirmStatusDelivery']);
215215
Route::apiResource('sellers', SellerController::class);
216216
Route::apiResource('categories', CategoryController::class);
217-
Route::delete('/category/{id}', [CategoryController::class, 'destroy']);
217+
Route::delete('admin/category/{id}', [CategoryController::class, 'destroy']);
218218
Route::apiResource('towns', TownController::class);
219219
Route::apiResource('quarters', QuarterController::class);
220220
Route::apiResource('admin/customers', CustomerController::class);

0 commit comments

Comments
 (0)