codigo actual del servidor, con avances de joan
This commit is contained in:
23
app/Http/Resources/V2/Seller/AttributeCollection.php
Normal file
23
app/Http/Resources/V2/Seller/AttributeCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AttributeCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name,
|
||||
'values' => $this->attribute_values
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/Seller/AuctionProductBidCollection.php
Normal file
38
app/Http/Resources/V2/Seller/AuctionProductBidCollection.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AuctionProductBidCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'customer_name' => $data->user->name,
|
||||
'customer_email' => $data->user->email ?? '',
|
||||
'customer_phone' => $data->user->phone ?? '',
|
||||
'bidded_amout' => format_price($data->amount),
|
||||
// 'date' => date("d-m-Y", $this->created_at),
|
||||
'date' => $data->created_at->format('d-m-Y'),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Resources/V2/Seller/AuctionProductCollection.php
Normal file
34
app/Http/Resources/V2/Seller/AuctionProductCollection.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AuctionProductCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'main_price' => single_price($data->starting_bid),
|
||||
'start_date' => date('Y-m-d H:i:s', $data->auction_start_date),
|
||||
'end_date' => date('Y-m-d H:i:s', $data->auction_end_date),
|
||||
'total_bids' => (int) $data->bids->count(),
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->id),
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AuctionProductDetailsResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
'lang' => $this->lang,
|
||||
'product_name' => $this->getTranslation('name', $this->lang),
|
||||
"category_id" => $this->category_id,
|
||||
"brand_id" => $this->brand_id,
|
||||
'product_unit' => $this->getTranslation('unit', $this->lang),
|
||||
"weight" => $this->weight,
|
||||
"tags" => $this->tags,
|
||||
"photos" => new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->photos))->get()),
|
||||
"thumbnail_img" => new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->thumbnail_img))->get()),
|
||||
"video_provider" => $this->video_provider,
|
||||
"video_link" => $this->video_link,
|
||||
"starting_bid" => $this->starting_bid,
|
||||
"auction_start_date" => date("Y-m-d", $this->auction_start_date),
|
||||
"auction_end_date" => date("Y-m-d", $this->auction_end_date),
|
||||
'description' => $this->getTranslation('description', $this->lang),
|
||||
"shipping_type" => $this->shipping_type,
|
||||
"shipping_cost" => $this->shipping_cost,
|
||||
"cash_on_delivery" => $this->cash_on_delivery,
|
||||
"est_shipping_days" => $this->est_shipping_days,
|
||||
"tax" => $this->taxes,
|
||||
"tax_type" => $this->tax_type,
|
||||
"pdf" => new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->pdf))->get()),
|
||||
"meta_title" => $this->meta_title,
|
||||
"meta_description" => $this->meta_description,
|
||||
"meta_img" => new UploadedFileCollection(Upload::where("id",$this->meta_img)->get()),
|
||||
"slug" => $this->slug,
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
23
app/Http/Resources/V2/Seller/BrandCollection.php
Normal file
23
app/Http/Resources/V2/Seller/BrandCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BrandCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name,
|
||||
'icon' => uploaded_asset($this->logo)
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/CategoriesCollection.php
Normal file
29
app/Http/Resources/V2/Seller/CategoriesCollection.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CategoriesCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'parent_id' => $this->parent_id,
|
||||
'level' => $this->level,
|
||||
'name' =>$this->name,
|
||||
'banner' =>uploaded_asset($this->banner),
|
||||
'icon' => uploaded_asset($this->icon),
|
||||
'featured' =>$this->featured==0?false:true,
|
||||
'digital' =>$this->digital==0?false:true,
|
||||
'child' => ChildCategoriesCollection::collection( $this->childrenCategories)
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/ChildCategoriesCollection.php
Normal file
29
app/Http/Resources/V2/Seller/ChildCategoriesCollection.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ChildCategoriesCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'parent_id' => $this->parent_id,
|
||||
'level' => $this->level,
|
||||
'name' =>$this->name,
|
||||
'banner' =>uploaded_asset($this->banner),
|
||||
'icon' => uploaded_asset($this->icon),
|
||||
'featured' =>$this->featured==0?false:true,
|
||||
'digital' =>$this->digital==0?false:true,
|
||||
'child' => $this->categories?ChildCategoriesCollection::collection($this->categories):[]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/V2/Seller/ColorCollection.php
Normal file
23
app/Http/Resources/V2/Seller/ColorCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ColorCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name,
|
||||
'code' => $this->code
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/CommissionHistoryResource.php
Normal file
29
app/Http/Resources/V2/Seller/CommissionHistoryResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CommissionHistoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$order_code = 'Order Deleted';
|
||||
if(isset($this->order)){
|
||||
$order_code = $this->order->code;
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'order_code' => $order_code,
|
||||
'admin_commission' => $this->admin_commission,
|
||||
'seller_earning' => format_price($this->seller_earning),
|
||||
'created_at' => date('d-m-Y', strtotime($this->created_at)),
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Http/Resources/V2/Seller/ConversationCollection.php
Normal file
43
app/Http/Resources/V2/Seller/ConversationCollection.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ConversationCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$seen_status = false;
|
||||
if (
|
||||
(auth()->user()->id == $data->sender_id && $data->sender_viewed == 0) ||
|
||||
(auth()->user()->id == $data->receiver_id && $data->receiver_viewed == 0)
|
||||
) {
|
||||
$seen_status = true;
|
||||
}
|
||||
if (auth()->user()->id == $data->sender_id) {
|
||||
$image = uploaded_asset($data->receiver->avatar_original);
|
||||
$name = $data->receiver->name;
|
||||
} else {
|
||||
$image = uploaded_asset($data->sender->avatar_original);
|
||||
$name = $data->sender->name;
|
||||
}
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'image' => $image,
|
||||
'name' => $name,
|
||||
'title' => $data->title,
|
||||
'is_seen' => $seen_status,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ConversationMessageCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$image = null;
|
||||
$is_seller_message = false;
|
||||
|
||||
if($this->user != null){
|
||||
$image = uploaded_asset($this->user->avatar_original);
|
||||
}
|
||||
if($this->user->id == auth()->user->id) {
|
||||
$is_seller_message = true;
|
||||
}
|
||||
return [
|
||||
'image' => $image,
|
||||
'id' => $this->user->id,
|
||||
'name' => $this->user->name,
|
||||
'message' => $this->message,
|
||||
'is_seller_message' => $is_seller_message,
|
||||
'created_at' => $this->created_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/ConversationResource.php
Normal file
29
app/Http/Resources/V2/Seller/ConversationResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ConversationResource extends JsonResource
|
||||
{
|
||||
|
||||
public function toArray($request)
|
||||
{
|
||||
//dd(uploaded_asset($this->sender->avatar_original));
|
||||
$image="";
|
||||
$name="";
|
||||
if (auth()->user()->id == $this->sender_id) {
|
||||
$image = uploaded_asset($this->receiver->avatar_original);
|
||||
$name = $this->receiver->name;
|
||||
} else {
|
||||
$image = uploaded_asset($this->sender->avatar_original);
|
||||
$name = $this->sender->name;
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'image' => $image,
|
||||
'name' => $name,
|
||||
'title' => $this->title,
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/Seller/CouponResource.php
Normal file
38
app/Http/Resources/V2/Seller/CouponResource.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class CouponResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if($this->type == 'product_base') {
|
||||
|
||||
$decoded_product = Arr::pluck(json_decode($this->details, true), 'product_id');
|
||||
$products = filter_products(Product::whereIn('id', $decoded_product))->get();
|
||||
|
||||
}
|
||||
|
||||
// dd(json_encode(new ProductCollection($products)));
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'type' => $this->type,
|
||||
'code' => $this->code,
|
||||
'details' => ($this->type == 'product_base') ?json_encode( new ProductCollection($products)) : $this->details,
|
||||
'discount' =>(float) $this->discount,
|
||||
'discount_type' => $this->discount_type,
|
||||
'start_date' => date('d/m/Y', $this->start_date),
|
||||
'end_date' => date('d/m/Y', $this->end_date),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/V2/Seller/OrderCollection.php
Normal file
30
app/Http/Resources/V2/Seller/OrderCollection.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class OrderCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'order_code' => $data->code,
|
||||
'total' => format_price($data->grand_total),
|
||||
'order_date' => date('d-m-Y', strtotime($data->created_at)),
|
||||
'payment_status' => $data->payment_status,
|
||||
'delivery_status' => join(" ", explode('_', $data->delivery_status)),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/Seller/OrderDetailResource.php
Normal file
37
app/Http/Resources/V2/Seller/OrderDetailResource.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderDetailResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
|
||||
$shipping_address = json_decode($this->shipping_address);
|
||||
return [
|
||||
'order_code' => $this->code,
|
||||
'total' => format_price($this->grand_total),
|
||||
'order_date' => date('d-m-Y', strtotime($this->created_at)),
|
||||
'payment_status' => $this->payment_status,
|
||||
'payment_type' => ucwords(str_replace('_', ' ', $this->payment_type)),
|
||||
'delivery_status' => $this->delivery_status,
|
||||
'shipping_type' => $this->shipping_type,
|
||||
'payment_method' => $this->payment_type,
|
||||
'shipping_address' => $shipping_address,
|
||||
'shipping_cost' => format_price($this->orderDetails->sum('shipping_cost')),
|
||||
'subtotal' => format_price($this->orderDetails->sum('price')),
|
||||
'coupon_discount' => format_price($this->coupon_discount),
|
||||
'tax' => format_price($this->orderDetails->sum('tax')),
|
||||
'order_items' => OrderItemResource::collection($this->orderDetails)
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/V2/Seller/OrderItemResource.php
Normal file
30
app/Http/Resources/V2/Seller/OrderItemResource.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderItemResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$description = $this->quantity;
|
||||
if($this->variation) {
|
||||
$description = $this->quantity. ' x '. $this->variation;
|
||||
}
|
||||
return [
|
||||
'name' => optional($this->product)->name,
|
||||
'description' => $description,
|
||||
'delivery_status' => $this->delivery_status,
|
||||
'price' => format_price($this->price),
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/Seller/ProductCollection.php
Normal file
38
app/Http/Resources/V2/Seller/ProductCollection.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ProductCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$qty = 0;
|
||||
foreach ($data->stocks as $key => $stock) {
|
||||
$qty += $stock->qty;
|
||||
}
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->name,
|
||||
'thumbnail_img' => uploaded_asset($data->thumbnail_img),
|
||||
'price' => format_price($data->unit_price),
|
||||
'current_stock' => $qty,
|
||||
'status' => $data->published == 0 ? false : true,
|
||||
'category' => $data->category->name,
|
||||
'featured' => $data->seller_featured == 0 ? false : true,
|
||||
];
|
||||
}),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
89
app/Http/Resources/V2/Seller/ProductDetailsCollection.php
Normal file
89
app/Http/Resources/V2/Seller/ProductDetailsCollection.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductDetailsCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
'lang' => $this->lang,
|
||||
'product_name' => $this->getTranslation('name', $this->lang),
|
||||
'product_unit' => $this->getTranslation('unit', $this->lang),
|
||||
'description' => $this->getTranslation('description', $this->lang),
|
||||
"category_id" => $this->category_id,
|
||||
"brand_id" => $this->brand_id,
|
||||
"photos" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->photos))->get()),
|
||||
"thumbnail_img" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->thumbnail_img))->get()),
|
||||
"video_provider" => $this->video_provider,
|
||||
"video_link" => $this->video_link,
|
||||
"tags" => $this->tags,
|
||||
"unit_price" => $this->unit_price,
|
||||
"purchase_price" => $this->purchase_price,
|
||||
"variant_product" => $this->variant_product,
|
||||
"attributes" => json_decode($this->attributes),
|
||||
"choice_options" => json_decode($this->choice_options),
|
||||
"colors" => json_decode($this->colors),
|
||||
"variations" => $this->variations,
|
||||
"stocks" => new StockCollection($this->stocks),
|
||||
"todays_deal" => $this->todays_deal,
|
||||
"published" => $this->published,
|
||||
"approved" => $this->approved,
|
||||
"stock_visibility_state" => $this->stock_visibility_state,
|
||||
"cash_on_delivery" => $this->cash_on_delivery,
|
||||
"featured" => $this->featured,
|
||||
"seller_featured" => $this->seller_featured,
|
||||
"current_stock" => $this->current_stock,
|
||||
"weight" => $this->weight,
|
||||
"min_qty" => $this->min_qty,
|
||||
"low_stock_quantity" => $this->low_stock_quantity,
|
||||
"discount" => $this->discount,
|
||||
"discount_type" => $this->discount_type,
|
||||
"discount_start_date" => date("Y-m-d", $this->discount_start_date),
|
||||
"discount_end_date" => date("Y-m-d", $this->discount_end_date),
|
||||
"tax" => $this->taxes,
|
||||
"tax_type" => $this->tax_type,
|
||||
"shipping_type" => $this->shipping_type,
|
||||
"shipping_cost" => $this->shipping_cost,
|
||||
"is_quantity_multiplied" => $this->is_quantity_multiplied,
|
||||
"est_shipping_days" => $this->est_shipping_days,
|
||||
"num_of_sale" => $this->num_of_sale,
|
||||
"meta_title" => $this->meta_title,
|
||||
"meta_description" => $this->meta_description,
|
||||
"meta_img" =>new UploadedFileCollection(Upload::where("id",$this->meta_img)->get()),
|
||||
"pdf" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->pdf))->get()),
|
||||
"slug" => $this->slug,
|
||||
"rating" => $this->rating,
|
||||
"barcode" => $this->barcode,
|
||||
"digital" => $this->digital,
|
||||
"auction_product" => $this->auction_product,
|
||||
"file_name" => $this->file_name,
|
||||
"file_path" => $this->file_path,
|
||||
"external_link" => $this->external_link,
|
||||
"external_link_btn" => $this->external_link_btn,
|
||||
"wholesale_product" => $this->wholesale_product,
|
||||
"created_at" => $this->created_at,
|
||||
"updated_at" => $this->updated_at,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Http/Resources/V2/Seller/ProductResource.php
Normal file
19
app/Http/Resources/V2/Seller/ProductResource.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/Seller/ProductReviewCollection.php
Normal file
37
app/Http/Resources/V2/Seller/ProductReviewCollection.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ProductReviewCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
// dd($this);
|
||||
return [
|
||||
"data"=>$this->collection->map( function ($data){
|
||||
return [
|
||||
"id"=> (int) $data->id,
|
||||
"rating"=>(int) $data->rating,
|
||||
"comment"=> $data->comment,
|
||||
"status"=>(int) $data->status,
|
||||
"updated_at"=> $data->updated_at,
|
||||
"product_name"=> $data->product_name,
|
||||
"user_id"=>(int) $data->user_id,
|
||||
"name"=> $data->name,
|
||||
"avatar"=> $data->avatar
|
||||
];
|
||||
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
27
app/Http/Resources/V2/Seller/SellerPackageResource.php
Normal file
27
app/Http/Resources/V2/Seller/SellerPackageResource.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SellerPackageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' => $this->getTranslation('name'),
|
||||
'logo' => uploaded_asset($this->logo),
|
||||
'product_upload_limit' =>(int) $this->product_upload_limit,
|
||||
'amount' => ($this->amount > 0) ? single_price($this->amount) : translate('Free'),
|
||||
'price' => (double) $this->amount,
|
||||
'duration' =>(int) $this->duration,
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/SellerPaymentResource.php
Normal file
29
app/Http/Resources/V2/Seller/SellerPaymentResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SellerPaymentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$payment_method = ucfirst(str_replace('_', ' ', $this->payment_method));
|
||||
if ($this->txn_code != null) {
|
||||
$payment_method = ucfirst(str_replace('_', ' ', $this->payment_method)). ' ' .translate('TRX ID'). ':' .$this->txn_code;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'amount' => format_price($this->amount),
|
||||
'payment_method' => $payment_method,
|
||||
'payment_date' => date('d-m-Y', strtotime($this->created_at)),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Resources/V2/Seller/SellerWithdrawResource.php
Normal file
28
app/Http/Resources/V2/Seller/SellerWithdrawResource.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SellerWithdrawResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$status = translate('Paid');
|
||||
if($this->status == 0) {
|
||||
$status = translate('Pending');
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'amount' => format_price($this->amount),
|
||||
'status' => $status,
|
||||
'created_at' => date('d-m-Y', strtotime($this->created_at)),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/V2/Seller/StockCollection.php
Normal file
35
app/Http/Resources/V2/Seller/StockCollection.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class StockCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
|
||||
return [
|
||||
"data" => $this->collection->map(function ($data) {
|
||||
return [
|
||||
"id" => (int) $data->id,
|
||||
"product_id" => $data->product_id,
|
||||
"variant" => $data->variant,
|
||||
"sku" => $data->sku,
|
||||
"price" => $data->price,
|
||||
"qty" => $data->qty,
|
||||
"image" =>new UploadedFileCollection(Upload::where("id",$data->image)->get())
|
||||
];
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/Http/Resources/V2/Seller/TaxCollection.php
Normal file
22
app/Http/Resources/V2/Seller/TaxCollection.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TaxCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use App\Models\WholesalePrice;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class WholesaleProductDetailsCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
'lang' => $this->lang,
|
||||
'product_name' => $this->getTranslation('name', $this->lang),
|
||||
'product_unit' => $this->getTranslation('unit', $this->lang),
|
||||
'description' => $this->getTranslation('description', $this->lang),
|
||||
"category_id" => $this->category_id,
|
||||
"brand_id" => $this->brand_id,
|
||||
"photos" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->photos))->get()),
|
||||
"thumbnail_img" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->thumbnail_img))->get()),
|
||||
"video_provider" => $this->video_provider,
|
||||
"video_link" => $this->video_link,
|
||||
"tags" => $this->tags,
|
||||
"unit_price" => $this->unit_price,
|
||||
"purchase_price" => $this->purchase_price,
|
||||
"variant_product" => $this->variant_product,
|
||||
"attributes" => json_decode($this->attributes),
|
||||
"choice_options" => json_decode($this->choice_options),
|
||||
"colors" => json_decode($this->colors),
|
||||
"variations" => $this->variations,
|
||||
"stocks" => new StockCollection($this->stocks),
|
||||
"todays_deal" => $this->todays_deal,
|
||||
"published" => $this->published,
|
||||
"approved" => $this->approved,
|
||||
"stock_visibility_state" => $this->stock_visibility_state,
|
||||
"cash_on_delivery" => $this->cash_on_delivery,
|
||||
"featured" => $this->featured,
|
||||
"seller_featured" => $this->seller_featured,
|
||||
"current_stock" => $this->current_stock,
|
||||
"weight" => $this->weight,
|
||||
"min_qty" => $this->min_qty,
|
||||
"low_stock_quantity" => $this->low_stock_quantity,
|
||||
"discount" => $this->discount,
|
||||
"discount_type" => $this->discount_type,
|
||||
"discount_start_date" => date("Y-m-d", $this->discount_start_date),
|
||||
"discount_end_date" => date("Y-m-d", $this->discount_end_date),
|
||||
"tax" => $this->taxes,
|
||||
"tax_type" => $this->tax_type,
|
||||
"shipping_type" => $this->shipping_type,
|
||||
"shipping_cost" => $this->shipping_cost,
|
||||
"is_quantity_multiplied" => $this->is_quantity_multiplied,
|
||||
"est_shipping_days" => $this->est_shipping_days,
|
||||
"num_of_sale" => $this->num_of_sale,
|
||||
"meta_title" => $this->meta_title,
|
||||
"meta_description" => $this->meta_description,
|
||||
"meta_img" =>new UploadedFileCollection(Upload::where("id",$this->meta_img)->get()),
|
||||
"pdf" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->pdf))->get()),
|
||||
"slug" => $this->slug,
|
||||
"barcode" => $this->barcode,
|
||||
"file_name" => $this->file_name,
|
||||
"file_path" => $this->file_path,
|
||||
"external_link" => $this->external_link,
|
||||
"refundable"=>$this->refundable,
|
||||
"external_link_btn" => $this->external_link_btn,
|
||||
"wholesale_prices" =>WholesalePrice::where('product_stock_id',$this->stocks->first()->id)->get(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user