<?php

namespace App\Http\Resources;

use App\Room;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * @property mixed id
 * @property mixed type
 */
class RoomResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $name = descriptions(Room::find($this->id))->name;
        return [
            'id' => $this->id,
            'type' => $this->type,
            'name' => $name,
        ];
    }
}
