<?php

namespace Modules\School\Resources\Api;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Canteen\Resources\Api\CanteenResource;
use Modules\City\Resources\Api\CityResource;

class SchoolResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => (int) $this->id,
            'code' => (int) $this->code,
            'name' => $this->currentDescription->title ?? "",
            'active' => $this->active,
            'city' => new CityResource($this->city),
            'canteen' => new CanteenResource($this->canteen),
        ];
    }

}
