Actualizacuion de Rama Kquiroz

This commit is contained in:
ellecio2
2023-09-04 19:53:37 -04:00
parent d2e9ba53ab
commit 2e99d7b290
2206 changed files with 100145 additions and 467275 deletions

View File

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

View File

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