<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Carbon\Carbon;

class AnnouncementResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'description' => $this->description,
            'segments' => $this->segments,
            'starting_on' => Carbon::parse($this->starting_on)->format('d-m-Y'),
            'ending_on' => Carbon::parse($this->ending_on)->format('d-m-Y'),
            'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'),
        ];
    }
}
