Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/syn.corals.io/Corals/modules/Utility/Transformers/API/Comment/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/syn.corals.io/Corals/modules/Utility/Transformers/API/Comment/CommentTransformer.php
<?php

namespace Corals\Modules\Utility\Transformers\API\Comment;

use Corals\Foundation\Transformers\APIBaseTransformer;
use Corals\Modules\Utility\Models\Comment\Comment;

class CommentTransformer extends APIBaseTransformer
{
    /**
     * @param Comment $comment
     * @return array
     * @throws \Throwable
     */
    public function transform(Comment $comment)
    {
        $commentable_title = optional($comment->commentable)->getIdentifier();
        $comment_author = optional($comment->comment_author);

        $transformedArray = [
            'id' => $comment->id,
            'body' => $comment->body,
            'commentable_id' => $comment->commentable_id,
            'commentable' => $commentable_title,
            'author_id' => $comment->comment_author_id,
            'author' => $comment_author,
            'comments' => (new CommentPresenter())->present($comment->comments)['data'],
            'created_at' => format_date($comment->created_at),
        ];

        return parent::transformResponse($transformedArray);
    }
}

Spamworldpro Mini