<?php namespace Eae\Transformation\Transformer;

use League\Fractal;
use Infographic;

class InfographicTransformer extends Fractal\TransformerAbstract
{

    public function transform(Infographic $infographic)
    {

        // SEO IMAGE
        $image = $infographic->metaImage;

        return [
            'id'               => (int)$infographic->id,
            'title'            => $infographic->title,
            'content'          => nl2br($infographic->content),
            'template'         => $infographic->template,
            'inside_text'      => $infographic->inside_text === "yes",
            'meta_title'       => $infographic->meta_title,
            'meta_description' => $infographic->meta_description,
            'meta_image'       => isset($image->filename) ? getMediaUrl($image->filename, '1200x630') : '',
        ];
    }
}