<?php

namespace Litecms\Advertisement\Repositories\Presenter;

use League\Fractal\TransformerAbstract;
use Hashids;

class AdvertisementTransformer extends TransformerAbstract
{
    public function transform(\Litecms\Advertisement\Models\Advertisement $advertisement)
    {
        return [
            'id'                => $advertisement->getRouteKey(),
            'key'               => [
                'public'    => $advertisement->getPublicKey(),
                'route'     => $advertisement->getRouteKey(),
            ], 
            'id'                => $advertisement->id,
            'user_id'           => $advertisement->user_id,
            'slug'              => $advertisement->slug,
            'title'             => $advertisement->title,
            'details'           => $advertisement->details,
            'image'             => $advertisement->image,
            'region'            => $advertisement->region,
            'order'             => $advertisement->order,
            'size'              => $advertisement->size,
            'upload_folder'     => $advertisement->upload_folder,
            'status'            => $advertisement->status,
            'created_at'        => $advertisement->created_at,
            'updated_at'        => $advertisement->updated_at,
            'deleted_at'        => $advertisement->deleted_at,
            'url'               => [
                'public'    => trans_url('advertisement/'.$advertisement->getPublicKey()),
                'user'      => guard_url('advertisement/advertisement/'.$advertisement->getRouteKey()),
            ], 
            'status'            => trans('app.'.$advertisement->status),
            'created_at'        => format_date($advertisement->created_at),
            'updated_at'        => format_date($advertisement->updated_at),
        ];
    }
}