mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-14 15:39:37 -06:00
Sometime emoji's would randomly not render due to VueJS being reactive and during DOM updates, it would just cause it to be wacky! By parsing the emoji's server side before VueJS renders the dom, we now solve this issue.
31 lines
876 B
PHP
31 lines
876 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 UserResource($this->whenLoaded('user')),
|
||
'chatroom' => new ChatRoomResource($this->whenLoaded('chatroom')),
|
||
'message' => $emojiOne->toImage(Bbcode::parse("[left]{$this->message}[/left]")),
|
||
'created_at' => $this->created_at->format('F jS h:i A'),
|
||
'updated_at' => $this->updated_at
|
||
];
|
||
}
|
||
}
|