%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/ProjectDetailTransformer.php

<?php

namespace App\Transformers;

use App\Models\Project;

class ProjectDetailTransformer extends BaseTransformer
{
    protected $defaultIncludes = [
        'files',
        'services',
    ];

    public function includeFiles(Project $project)
    {
        return $this->collection($project->getDocuments(), new MediaTransformer, 'files');
    }

    public function includeServices(Project $project)
    {
        return $this->collection($project->services, new ServiceTransformer, 'services');
    }

    /**
     * @param Project $project
     *
     * @return array
     */
    public function transform(Project $project)
    {
        return [
            'id'                       => $project->id,
            'code'                     => $project->code,
            'name'                     => $project->name,
            'location'                 => $project->location,
            'person_responsible'       => $project->person_responsible,
            'person_responsible_email' => $project->person_responsible_email,
            'person_responsible_phone' => $project->person_responsible_phone,
            'due_date'                 => $project->due_date,
            'status'                   => $project->status,
            'client'                   => $project->client->companyProfile->name,
            'client_id'                => $project->client_id,
            'can_edit'                 => $project->canEdit(),
            'can_upload_files'         => $project->canUploadFiles(),
            'can_delete_files'         => $project->canDeleteFiles(),
            'can_request_quotation'    => $project->canRequestQuotation(),
            'can_accept_quotation'     => $project->canAcceptQuotation(),
            'can_update_status'        => $project->canUpdateStatus(),
            'logo'                     => $project->getLogo(),
        ];
    }
}

Zerion Mini Shell 1.0