Files
UNIT3D-Community-Edition/app/Http/Resources/ChatMessageResource.php
Poppabear 82f0378856 (Fix) Bug: Emoji Parsing Issue
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.
2018-05-10 21:13:17 -04:00

31 lines
876 B
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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
];
}
}