%PDF- %PDF-
Mini Shell

Mini Shell

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

<?php

namespace App\Transformers;

use App\Models\Pto;

class PtoTransformer extends BaseTransformer
{
    protected $defaultIncludes = [
        'user',
    ];

    protected $availableIncludes = [
        'approvedBy',
    ];

    public function includeUser(Pto $pto)
    {
        return $this->item($pto->user, new UserTransformer(), 'user');
    }

    public function includeApprovedBy(Pto $pto)
    {
        if ($user = $pto->approvedBy) {
            return $this->item($user, new UserTransformer(), 'user');
        }
        return null;
    }

    public function transform(Pto $pto)
    {
        return [
            'id'          => $pto->id,
            'start_date'  => $pto->formatDate($pto->start_date),
            'end_date'    => $pto->formatDate($pto->end_date),
            'notes'       => $pto->notes,
            'status'      => $pto->status,
            'can_delete'  => $pto->isDeletable(),
            'can_edit'    => $pto->isEditable(),
            'can_approve' => $pto->canApprove(),
            'can_reject'  => $pto->canReject(),
        ];
    }
}

Zerion Mini Shell 1.0