![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/job-board.corals.io/Corals/modules/Classified/Transformers/ |
<?php namespace Corals\Modules\Classified\Transformers; use Corals\Foundation\Transformers\BaseTransformer; use Corals\Modules\Classified\Models\Product; class ProductTransformer extends BaseTransformer { public function __construct($extras = []) { $this->resource_url = config('classified.models.product.resource_url'); parent::__construct($extras); } /** * @param Product $product * @return array * @throws \Throwable */ public function transform(Product $product) { $showUrl = $product->getShowURL(); $productName = $product->name; if ($product->is_featured) { $productName .= ' <i class="fa fa-star text-warning" title="Featured"></i>'; } $transformedArray = [ 'id' => $product->id, 'checkbox' => $this->generateCheckboxElement($product), 'image' => '<a href="' . $showUrl . '">' . '<img src="' . $product->image . '" class=" img-responsive" alt="' . $product->name . '" style="width: auto;max-height: 60px;max-width: 100px;"/></a>', 'name' => '<a href="' . $showUrl . '">' . $productName . '</a>', 'plain_name' => $productName, 'location' => $product->getLocation(), 'price' => \Payments::currency($product->price), 'caption' => $product->caption, 'visitors_count' => $product->visitors_count, 'status' => formatStatusAsLabels($product->status, ['text' => trans('Classified::attributes.product.status_options.' . $product->status)]), 'categories' => formatArrayAsLabels($product->categories->pluck('name'), 'success', '<i class="fa fa-folder-open"></i>'), 'tags' => generatePopover(formatArrayAsLabels($product->tags->pluck('name'), 'primary', '<i class="fa fa-tags"></i>')), 'description' => $product->description ? generatePopover($product->description) : '-', 'options' => formatArrayAsLabels($product->options ? $product->options->pluck('label') : ''), 'condition' => \Settings::get('classified_product_condition_options', [])[$product->condition] ?? '-', 'created_at' => format_date($product->created_at), 'updated_at' => format_date($product->updated_at), 'created_by' => "<a href='" . url('users/' . $product->user->hashed_id) . "'> {$product->user->full_name}</a>", 'action' => $this->actions($product) ]; return parent::transformResponse($transformedArray); } }