e0dfc3ec82
API CI/CD / Validate (composer + pint) (push) Successful in 3m15s
API CI/CD / Test (PHPUnit) (push) Failing after 5m4s
API CI/CD / Build frontend assets (push) Successful in 1m3s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Messaging;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class MessageResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id ?? null,
|
|
'sender_id' => $this->sender_id ?? null,
|
|
'recipient_id' => $this->recipient_id ?? null,
|
|
'subject' => $this->subject ?? null,
|
|
'message' => $this->message ?? null,
|
|
'sent_datetime' => optional($this->sent_datetime)->toDateTimeString(),
|
|
'read_status' => (bool) ($this->read_status ?? false),
|
|
'read_datetime' => optional($this->read_datetime)->toDateTimeString(),
|
|
'message_number' => $this->message_number ?? null,
|
|
'priority' => $this->priority ?? null,
|
|
'attachment' => $this->attachment ?? null,
|
|
'status' => $this->status ?? null,
|
|
'semester' => $this->semester ?? null,
|
|
'school_year' => $this->school_year ?? null,
|
|
'sender_name' => $this->whenLoaded('sender', fn () => trim($this->sender->firstname.' '.$this->sender->lastname), null),
|
|
'recipient_name' => $this->whenLoaded('recipient', fn () => trim($this->recipient->firstname.' '.$this->recipient->lastname), null),
|
|
];
|
|
}
|
|
}
|