<?php

namespace App\Http\Resources;

use App\Classes\ValueObjects\Constants\RoleTypes;
use Illuminate\Http\Resources\Json\JsonResource;

class UserResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $userTypeArray = RoleTypes::USER_TYPE_ID;
        return [
            'id' => $this->id,
            'name' => $this->name,
            'email' => $this->email,
            'type' => (int) $this->type,
            'type_name' => ($userTypeArray[(int) $this->type]),
            'status' => (int) $this->status
        ];
    }
}
