%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/diaspora/api/app/Transformers/App/
Upload File :
Create Path :
Current File : /var/www/html/diaspora/api/app/Transformers/App/MyCountrySectionDetailTransformer.php

<?php

namespace App\Transformers\App;

use App\Models\MyCountrySection;
use App\Transformers\BaseTransformer;
use App\Transformers\MyCountryCategoryTransformer;

class MyCountrySectionDetailTransformer extends BaseTransformer
{
    protected $defaultIncludes = [
        'category',
    ];

    public function includeCategory(MyCountrySection $section)
    {
        if ($category = $section->category) {
            return $this->item($category, new MyCountryCategoryTransformer, 'category');
        }
        return null;
    }


    /**
     * @param MyCountrySection $section
     *
     * @return array
     */
    public function transform(MyCountrySection $section)
    {
        return [
            'id'             => $section->id,
            'title'          => $section->title,
            'order'          => $section->order,
            'description'    => $section->description
                ? $this->injectStyles() . $section->description . $this->injectScripts()
                : '',
            'is_visible'     => $section->is_visible,
            'can_be_enabled' => $section->canBeEnabled(),
            'category_id'    => $section->category_id,
            'available_in'   => $section->translations()
                                        ->get()
                                        ->pluck('locale'),
            'created_at'     => $section->created_at,
            'updated_at'     => $section->updated_at,
        ];
    }
}

Zerion Mini Shell 1.0