<?php

namespace App\Http\Resources;

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

class User extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'full_name' => $this->first_name.' '.$this->last_name,
            'email' => $this->email,
            'role' => UserRoles::ROLES_NAMES[$this->role_id],
            'created_at' =>Carbon::parse($this->created_at)->format('d/m/Y')
        ];
    }
}
