%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/diaspora/api_internal/app/Transformers/
Upload File :
Create Path :
Current File : /var/www/html/diaspora/api_internal/app/Transformers/MyCountrySectionTransformer.php

<?php

namespace App\Transformers;

use App\Models\MyCountrySection;

class MyCountrySectionTransformer 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
                ?: '',
            '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