%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/workeasy-api/app/Transformers/
Upload File :
Create Path :
Current File : /var/www/html/workeasy-api/app/Transformers/CandidateTransformer.php

<?php

namespace Workeasy\Transformers;

use Workeasy\Models\Candidate;

/**
 * Created by PhpStorm.
 * User: User
 * Date: 1/26/2018
 * Time: 3:31 PM
 */
class CandidateTransformer extends BaseTransformer
{
    protected $availableIncludes = [
        'offers',
        'experiences',
        'interviews',
    ];

    public function includeOffers(Candidate $candidate)
    {
        if ($offer = $candidate->offers) {
            return $this->collection($offer, new OfferTransformer, 'offers');
        }
        return null;
    }

    public function includeExperiences(Candidate $candidate)
    {
        if ($experience = $candidate->experiences) {
            return $this->collection($experience, new ExperienceTransformer, 'experiences');
        }
        return null;
    }

    public function includeInterviews(Candidate $candidate)
    {
        if ($interviews = $candidate->interviews) {
            return $this->collection($interviews, new InterviewTransformer, 'interviews');
        }
        return null;
    }

    public function transform(Candidate $candidate)
    {
        $data = $this->transformColumns($candidate);
        $data['rating'] = $candidate->getRating();
        return $data;
    }

    protected function getTransformableColumns()
    {
        return [
            'id'           => 'id',
            'name'         => 'name',
            'surname'      => 'surname',
            'age'          => 'age',
            'description'  => 'description',
            'phone_number' => 'phone_number',
            'created_at'   => 'created_at',
            'updated_at'   => 'updated_at',
        ];
    }

}

Zerion Mini Shell 1.0