%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/camillo/camillo-api-master/app/Http/Resources/
Upload File :
Create Path :
Current File : /var/www/html/camillo/camillo-api-master/app/Http/Resources/CommunicationResource.php

<?php

namespace App\Http\Resources;

use App\Models\Event;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

class CommunicationResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {

        $data =  [
            'id' => $this->id,
            'subject' => $this->subject,
            'content' => $this->content,
            'sender' => [
                'name' => $this->sender->individual->name,
                'surname' => $this->sender->individual->surname
            ],
            'minor' => [
                'name' => $this->minor->name,
                'surname' => $this->minor->surname
            ],
            'classroom_name' => $this->classroom->class_name,
            'institute_name' => $this->classroom->institute->name,
            'notify' => $this->notify,
            'is_read' => $this->is_read,
            'date' => Carbon::parse($this->created_at)->format('d-m-Y'),
            'time' => Carbon::parse($this->created_at)->format('H:i')
        ];

        return $data;
    }
}

Zerion Mini Shell 1.0