<?php

namespace Litepie\Product\Repositories\Presenter;

use League\Fractal\TransformerAbstract;
use Hashids;

class ProductTransformer extends TransformerAbstract
{
    public function transform(\Litepie\Product\Models\Product $product)
    {
        return [
            'id'                => $product->getRouteKey(),
            'key'               => [
                'public'    => $product->getPublicKey(),
                'route'     => $product->getRouteKey(),
            ], 
            'title'             => $product->title,
            'tagline'           => $product->tagline,
            'parentcategory_id' => $product->parentcategory_id,
            'category_id'       => $product->category_id,
            'brand_id'          => $product->brand_id,
            'model_id'          => $product->model_id,
            'available_status'  => $product->available_status,
            'description'       => $product->description,
            'features'          => $product->features,
            'price'             => $product->price,
            'discount'          => $product->discount,
            'topic_subject'     => $product->topic_subject,
            'topic_style'       => $product->topic_style,
            'gendergroup'       => $product->gendergroup,
            'agegroup'          => $product->agegroup,
            'targetgroup'       => $product->targetgroup,
            'special_targetgroup' => $product->special_targetgroup,
            'budget'            => $product->budget,
            'time'              => $product->time,
            'location'          => $product->location,
            'delivery'          => $product->delivery,
            'email'             => $product->email,
            'phone'             => $product->phone,
            'website'           => $product->website,
            'logo'              => $product->logo,
            'cover_image'       => $product->cover_image,
            'gallery'           => $product->gallery,
            'is_deal'           => $product->is_deal,
            'discounted_price'  => $product->discounted_price,
            'special_conditions' => $product->special_conditions,
            'deal_valid_from'   => $product->deal_valid_from,
            'deal_valid_to'     => $product->deal_valid_to,
            'deal_publish_from' => $product->deal_publish_from,
            'deal_publish_to'   => $product->deal_publish_to,
            'is_auction'        => $product->is_auction,
            'ads_auction_from'  => $product->ads_auction_from,
            'ads_auction_to'    => $product->ads_auction_to,
            'slug'              => $product->slug,
            'user_id'           => $product->user_id,
            'deleted_at'        => $product->deleted_at,
            'url'               => [
                'public'    => trans_url('product/'.$product->getPublicKey()),
                'user'      => guard_url('product/product/'.$product->getRouteKey()),
            ], 
            'status'            => trans('app.'.$product->status),
            'created_at'        => format_date($product->created_at),
            'updated_at'        => format_date($product->updated_at),
        ];
    }
}