Files
UNIT3D-Community-Edition/app/Http/Resources/ChatMessageResource.php
HDVinnie 1dee25b7ca (Add) Missing License Blocks
- few files were missing NOTICE OF LICENSE
2018-11-05 18:51:45 -05:00

41 lines
1.2 KiB
PHP

<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author Poppabear
*/
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' => htmlspecialchars_decode($emojiOne->toImage(Bbcode::parse("[left]" . clean($this->message) . "[/left]"))),
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String()
];
}
}