* @created 2022-08-11 18:45:02 * @modified 2022-08-11 18:45:02 */ namespace Beike\Shop\Http\Resources; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class InquiryDetail extends JsonResource { /** * @param Request $request * @return array * @throws \Exception */ public function toArray($request): array { $productsku = $this->productsku; $product = $productsku->product; $description = $product->description; return [ 'id' => $this->id, 'product_sku_id' => $this->product_sku_id, 'contacts' => $this->contacts, 'email' => $this->email, 'content' => $this->content, 'product_sku_sku' => $productsku->sku, 'product_name' => $description->name ?? '', 'product_images' => array_map(function ($image) { return [ 'preview' => image_resize($image, 500, 500), 'popup' => image_resize($image, 800, 800), 'thumb' => image_resize($image, 150, 150), ]; }, $product->images ?? []), 'product_id' => $productsku->product_id, 'created_at' => time_format($this->created_at), 'updated_at' => time_format($this->updated_at), ]; } }