File: /mnt/data/ghayatcom/ghayatcom-api/app/Http/Resources/ChatResource.php
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* App\Http\Resources
*
* @property int $id
* @property int $appointment_id
* @property int $sender_id
* @property int $recipient_id
* @property mixed $message
* @property mixed $created_at
* @property object $sender
* @property string $getUserAttachment
* @property string $getFileAttach
* @property object $recipient
* @method string getUserAttachment()
* @method string getFileAttach()
*/
class ChatResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$RandomLibrary = new \App\Library\RandomLibrary;
return [
'id' => $this->id,
'appointment_id' => $this->appointment_id,
'sender_id' => $this->sender_id,
'sender_name' => trim($this->sender->first_name.' '.$this->sender->last_name),
'sender_image' => $this->sender->profile_image,
'recipient_id' => $this->recipient_id,
'recipient_name' => trim($this->recipient->first_name.' '.$this->recipient->last_name),
'recipient_image' => $this->recipient->profile_image,
'message' => $this->message,
'file_path' => $this->getUserAttachment(),
'file_attach' => $this->getFileAttach(),
'created_at' => $this->created_at,
];
}
}