File "OutstandingOrderResource.php"
Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Resources/Admin/OutstandingOrderResource.php
File size: 1.83 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace App\Http\Resources\Admin;
use Illuminate\Http\Resources\Json\JsonResource;
class OutstandingOrderResource extends JsonResource
{
public function toArray($request)
{
$sub_total = 0;
$user = $this->user;
foreach ($this->items as $item) {
$sub_total += $item->total_price_after_engraving;
}
$sub_total_after_discount = ($sub_total + $this->rush_order_amount) - $this->discount_total;
$grand_total = $sub_total_after_discount + $this->shipping_charges;
if ($this->waive_off_sales_tax != 1) {
$grand_total += $this->sales_tax_amount;
}
return [
'id' => $this->id,
'rush_order' => $this->rush_order,
'order_number' => $this->order_number,
'purchase_order_number' => $this->purchase_order_number,
'payment_status' => $this->payment_status,
'payment_date' => $this->formated_payment_date,
'delivery_date' => $this->delivery_date?->format('m-d-Y'),
'event_date' => $this->event_date?->format('m-d-Y'),
'date_scheduled' => $this->date_scheduled?->format('m-d-Y'),
'date_pick_or_ship_by' => $this->date_pick_or_ship_by?->format('m-d-Y'),
'delivery_type' => $this->delivery_type,
'current_status' => $this->current_status?->name,
'waive_off_sales_tax' => $this->waive_off_sales_tax,
'waive_off_sales_tax_reason' => $this->waive_off_sales_tax_reason,
'grand_total' => '$'.(number_format($grand_total, 2)),
'created_at' => $this->created_at->format('m-d-Y'),
'user' => $user ? [
'name' => $user->name,
'email' => $user->email,
'phone_number' => $user->phone_number,
] : [],
];
}
}