<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;

class PostCommentCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return parent::toArray($request);
    }

    public function withResponse($request, $response)
    {
        $charset = $request->header('Accept-Charset', 'utf-8');
        if ($charset === 'utf-8') {
            $response->header('Charset', 'utf-8');
            $response->header('Content-Type','application/json; charset=utf-8');
            $response->setEncodingOptions(JSON_UNESCAPED_UNICODE);
        }
    }
}
