<?php

namespace Boomee\Service\Repositories\Presenter;

use League\Fractal\TransformerAbstract;
use Hashids;

class DealTransformer extends TransformerAbstract
{
    public function transform(\Boomee\Service\Models\Deal $deal)
    {
        return [
            'id'                => $deal->getRouteKey(),
            'key'               => [
                'public'    => $deal->getPublicKey(),
                'route'     => $deal->getRouteKey(),
            ], 
            'category_id'       => $deal->category_id,
            'country_id'        => $deal->country_id,
            'state_id'          => $deal->state_id,
            'city_id'           => $deal->city_id,
            'user_id'           => $deal->user_id,
            'type'              => $deal->type,
            'title'             => $deal->title,
            'images'            => $deal->images,
            'description'       => $deal->description,
            'features'          => $deal->features,
            'price'             => $deal->price,
            'expire_date'       => $deal->expire_date,
            'media_id'          => $deal->media_id,
            'target_group'      => $deal->target_group,
            'age_group'         => $deal->age_group,
            'topics'            => $deal->topics,
            'brands'            => $deal->brands,
            'tags'              => $deal->tags,
            'is_deal'           => $deal->is_deal,
            'deal_price'        => $deal->deal_price,
            'discount'          => $deal->discount,
            'discount_price'    => $deal->discount_price,
            'conditions'        => $deal->conditions,
            'valid_from'        => $deal->valid_from,
            'valid_to'          => $deal->valid_to,
            'publish_from'      => $deal->publish_from,
            'publish_to'        => $deal->publish_to,
            'slug'              => $deal->slug,
            'user_type'         => $deal->user_type,
            'deleted_at'        => $deal->deleted_at,
            'url'               => [
                'public'    => trans_url('service/'.$deal->getPublicKey()),
                'user'      => guard_url('service/deal/'.$deal->getRouteKey()),
            ], 
            'status'            => trans('app.'.$deal->status),
            'created_at'        => format_date($deal->created_at),
            'updated_at'        => format_date($deal->updated_at),
        ];
    }
}