mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-26 04:59:16 -05:00
31 lines
896 B
PHP
31 lines
896 B
PHP
<?php
|
||
|
||
namespace App\Http\Resources;
|
||
|
||
use App\Helpers\Bbcode;
|
||
use ChristofferOK\LaravelEmojiOne\LaravelEmojiOne;
|
||
use Illuminate\Http\Resources\Json\JsonResource;
|
||
|
||
class ChatMessageResource extends JsonResource
|
||
{
|
||
/**
|
||
* Transform the resource into an array.
|
||
*
|
||
* @param \Illuminate\Http\Request $request
|
||
* @return array
|
||
*/
|
||
public function toArray($request)
|
||
{
|
||
$emojiOne = app()->make(LaravelEmojiOne::class);
|
||
|
||
return [
|
||
'id' => $this->id,
|
||
'user' => new ChatUserResource($this->whenLoaded('user')),
|
||
'chatroom' => new ChatRoomResource($this->whenLoaded('chatroom')),
|
||
'message' => $emojiOne->toImage(Bbcode::parse("[left]{$this->message}[/left]")),
|
||
'created_at' => $this->created_at->toIso8601String(),
|
||
'updated_at' => $this->updated_at->toIso8601String()
|
||
];
|
||
}
|
||
}
|