discounted prods

This commit is contained in:
merdan 2023-02-16 15:00:43 +05:00
parent 986c57ffa6
commit 29e49bd209
3 changed files with 4 additions and 20 deletions

View File

@ -24,7 +24,7 @@ class Wishlists extends WishlistController
$customer = $request->user(); $customer = $request->user();
return response([ return response([
'data' => WishListResource::collection($customer->wishlist_items()->get()), 'data' => WishListResource::collection($customer->wishlist_items()->paginate(10)),
]); ]);
} }

View File

@ -16,7 +16,7 @@ class Product extends JsonResource
*/ */
public function toArray($request) public function toArray($request)
{ {
$product = $this->product ? $this->product : $this; $product = $this->product ?: $this;
return [ return [
/* product's information */ /* product's information */
@ -24,9 +24,6 @@ class Product extends JsonResource
'type' => $product->type, 'type' => $product->type,
'name' => $product->name, 'name' => $product->name,
'description' => $product->description, 'description' => $product->description,
// 'is_wishlisted' => $this->isWishlisted($product), //todo transfer to mobile
// 'is_item_in_cart' => \Cart::hasProduct($product),//todo transfer to mobile
// 'shop_title' => $this->shop_title,
'brand' => $product->brand->name ?? '', 'brand' => $product->brand->name ?? '',
'images' => ProductImage::collection($product->images), 'images' => ProductImage::collection($product->images),
'color_count' => $this->related_products->count(), 'color_count' => $this->related_products->count(),
@ -49,7 +46,7 @@ class Product extends JsonResource
$product = $variant->product; $product = $variant->product;
}else{ }else{
$product = $this->product ? $this->product : $this; $product = $this->product ?: $this;
} }
$typeInstance = $product->getTypeInstance(); $typeInstance = $product->getTypeInstance();
@ -70,17 +67,4 @@ class Product extends JsonResource
), ),
]; ];
} }
// private function isWishlisted($product):bool
// {
// $wishlist = false;
//
// if ($customer = auth('sanctum')->user() && $wishlist = auth('sanctum')->user()->wishlist_items) {
// $wishlist = $wishlist->filter(function ($item) use ($product) {
// return $item->product_id == $product->product_id;
// })->first();
// }
//
// return $wishlist ? true : false;
// }
} }

View File

@ -21,7 +21,7 @@ class WishListResource extends JsonResource
'created_at' => $this->created_at, 'created_at' => $this->created_at,
'updated_at' => $this->updated_at, 'updated_at' => $this->updated_at,
'old_price' => (double) core()->convertPrice($this->price), 'old_price' => (double) core()->convertPrice($this->price),
'old_price_formatted' => (double) core()->currency($this->price), 'old_price_formatted' => core()->currency($this->price),
]; ];
} }
} }