Actualizacuion de Rama Kquiroz
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Auction;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderDetail;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AuctionBidProducts 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 = null;
|
||||
$isBuyable = false;
|
||||
$my_bided_product = $this->bids->where('user_id', auth()->id())->first();
|
||||
$highest_bid = $this->bids->max('amount');
|
||||
$order_detail = OrderDetail::where('product_id', $this->id)->first();
|
||||
if ($order_detail != null) {
|
||||
$order = Order::where('id', $order_detail->order_id)->where('user_id', auth()->id())->first();
|
||||
}
|
||||
|
||||
if ($my_bided_product->product->auction_end_date < strtotime("now") && $my_bided_product->amount == $highest_bid && $order == null) {
|
||||
$action = 'Buy';
|
||||
$isBuyable = true;
|
||||
} elseif ($order != null) {
|
||||
$action = 'Purchased';
|
||||
} else {
|
||||
$action = 'N/A';
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'thumbnail_image' => uploaded_asset($this->thumbnail_img),
|
||||
'my_bid' => single_price($my_bided_product->amount),
|
||||
'highest_bid' => single_price($highest_bid),
|
||||
'auction_end_date' => $this->auction_end_date < strtotime("now") ? translate('Ended') : date('d.m.Y H:i:s', $this->auction_end_date),
|
||||
'action' => $action,
|
||||
'isBuyable' => $isBuyable,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Auction;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AuctionPurchaseHistory 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 = \App\Models\Order::find($this->id);
|
||||
return [
|
||||
'id' => $order->id,
|
||||
'code' => $order->code,
|
||||
'date' => date('d-m-Y', $order->date),
|
||||
'amount' => single_price($order->grand_total),
|
||||
'delivery_status' => translate(ucfirst(str_replace('_', ' ', $order->orderDetails->first()->delivery_status))),
|
||||
'payment_status' => $order->payment_status == 'paid' ? translate('Paid') : translate('Unpaid'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,13 @@ class PurchaseHistoryCollection extends ResourceCollection
|
||||
'payment_status' => $data->payment_status,
|
||||
'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)),
|
||||
'delivery_status' => $data->delivery_status,
|
||||
'delivery_status_string' => $data->delivery_status == 'pending'? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'grand_total' => format_price($data->grand_total),
|
||||
'delivery_status_string' => $data->delivery_status == 'pending' ? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'grand_total' => format_price(convert_price($data->grand_total)),
|
||||
'plane_grand_total' => $data->grand_total,
|
||||
'coupon_discount' => format_price($data->coupon_discount),
|
||||
'shipping_cost' => format_price($data->orderDetails->sum('shipping_cost')),
|
||||
'subtotal' => format_price($data->orderDetails->sum('price')),
|
||||
'tax' => format_price($data->orderDetails->sum('tax')),
|
||||
'coupon_discount' => format_price(convert_price($data->coupon_discount)),
|
||||
'shipping_cost' => format_price(convert_price($data->orderDetails->sum('shipping_cost'))),
|
||||
'subtotal' => format_price(convert_price($data->orderDetails->sum('price'))),
|
||||
'tax' => format_price(convert_price($data->orderDetails->sum('tax'))),
|
||||
'date' => Carbon::createFromTimestamp($data->date)->format('d-m-Y'),
|
||||
'cancel_request' => $data->cancel_request == 1,
|
||||
'manually_payable' => $data->manual_payment && $data->manual_payment_data == null,
|
||||
|
||||
@@ -20,12 +20,14 @@ class PurchaseHistoryItemsCollection extends ResourceCollection
|
||||
$no_of_max_day = get_setting('refund_request_time');
|
||||
$last_refund_date = $data->created_at->addDays($no_of_max_day);
|
||||
$today_date = \Carbon\Carbon::now();
|
||||
if ($data->product != null &&
|
||||
if (
|
||||
$data->product != null &&
|
||||
$data->product->refundable != 0 &&
|
||||
$data->refund_request == null &&
|
||||
$today_date <= $last_refund_date &&
|
||||
$data->payment_status == 'paid' &&
|
||||
$data->delivery_status == 'delivered') {
|
||||
$data->delivery_status == 'delivered'
|
||||
) {
|
||||
$refund_button = true;
|
||||
} else if ($data->refund_request != null && $data->refund_request->refund_status == 0) {
|
||||
$refund_label = "Pending";
|
||||
@@ -47,10 +49,10 @@ class PurchaseHistoryItemsCollection extends ResourceCollection
|
||||
'product_id' => $data->product->id,
|
||||
'product_name' => $data->product->name,
|
||||
'variation' => $data->variation,
|
||||
'price' => format_price($data->price),
|
||||
'tax' => format_price($data->tax),
|
||||
'shipping_cost' => format_price($data->shipping_cost),
|
||||
'coupon_discount' => format_price($data->coupon_discount),
|
||||
'price' => format_price(convert_price($data->price)),
|
||||
'tax' => format_price(convert_price($data->tax)),
|
||||
'shipping_cost' => format_price(convert_price($data->shipping_cost)),
|
||||
'coupon_discount' => format_price(convert_price($data->coupon_discount)),
|
||||
'quantity' => (int)$data->quantity,
|
||||
'payment_status' => $data->payment_status,
|
||||
'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)),
|
||||
|
||||
@@ -10,17 +10,17 @@ class PurchaseHistoryMiniCollection extends ResourceCollection
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'code' => $data->code,
|
||||
'user_id' => intval($data->user_id),
|
||||
'payment_type' => ucwords(str_replace('_', ' ', $data->payment_type)) ,
|
||||
'payment_status' => $data->payment_status,
|
||||
'payment_type' => ucwords(str_replace('_', ' ', $data->payment_type)),
|
||||
'payment_status' => translate($data->payment_status),
|
||||
'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)),
|
||||
'delivery_status' => $data->delivery_status,
|
||||
'delivery_status_string' => $data->delivery_status == 'pending'? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'grand_total' => format_price($data->grand_total) ,
|
||||
'delivery_status' => translate($data->delivery_status),
|
||||
'delivery_status_string' => $data->delivery_status == 'pending' ? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'grand_total' => format_price(convert_price($data->grand_total)),
|
||||
'date' => Carbon::createFromTimestamp($data->date)->format('d-m-Y'),
|
||||
'links' => [
|
||||
'details' => ''
|
||||
|
||||
@@ -24,6 +24,8 @@ class AuctionProductCollection extends ResourceCollection
|
||||
'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(),
|
||||
'can_edit' => $data->auction_start_date > strtotime("now"),
|
||||
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->id),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class DigitalProductCollection 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_img' => uploaded_asset($data->thumbnail_img),
|
||||
'category' => $data->category->getTranslation('name'),
|
||||
'price ' => $data->unit_price,
|
||||
'status' => $data->published == 0 ? false : true,
|
||||
'featured' => $data->seller_featured == 0 ? false : true
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DigitalProductDetailsResource 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,
|
||||
"product_file" => new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->file_name))->get()),
|
||||
"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()),
|
||||
"meta_title" => $this->meta_title,
|
||||
"meta_description" => $this->meta_description,
|
||||
"meta_img" => new UploadedFileCollection(Upload::where("id",$this->meta_img)->get()),
|
||||
"slug" => $this->slug,
|
||||
"unit_price" => $this->unit_price,
|
||||
"purchase_price" => $this->purchase_price,
|
||||
"tax" => $this->taxes,
|
||||
"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),
|
||||
"description" => $this->getTranslation('description', $this->lang),
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,9 +10,9 @@ class WalletCollection extends ResourceCollection
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'amount' => format_price ($data->amount) ,
|
||||
'amount' => single_price(($data->amount)),
|
||||
'payment_method' => ucwords(str_replace('_', ' ', $data->payment_method)),
|
||||
'approval_string' => $data->offline_payment ? ($data->approval == 1 ? "Approved" : "Decliend") : "N/A",
|
||||
'date' => Carbon::createFromTimestamp(strtotime($data->created_at))->format('d-m-Y'),
|
||||
|
||||
Reference in New Issue
Block a user