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/Services/Comment/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/syn.corals.io/Corals/modules/Utility/Services/Comment/CommentService.php
<?php

namespace Corals\Modules\Utility\Services\Comment;

use Corals\Foundation\Services\BaseServiceClass;
use Corals\Modules\Utility\Classes\Comment\CommentManager;
use Corals\User\Models\User;
use net\authorize\api\contract\v1\TransactionRequestType\UserFieldsAType;

class CommentService extends BaseServiceClass
{
    /**
     * @param $data
     * @param $commentableClass
     * @param $commentable_hashed_id
     * @param null $author
     * @return \Corals\Modules\Utility\Models\Comment\Comment|\Illuminate\Database\Eloquent\Model
     */
    public function createComment($data, $commentableClass, $commentable_hashed_id, $author = null)
    {
        if (is_null($commentableClass)) {
            abort(400, 'Comment class is null');
        }

        $commentable = $commentableClass::findByHash($commentable_hashed_id);

        if (!$commentable) {
            abort(404, 'Not Found!!');
        }

        if (is_null($author) && user()) {
            $author = user();
        }

        $commentableManagerClass = new CommentManager($commentable, $author);

        return $commentableManagerClass->createComment([
            'body' => $data['body'],
            'status' => $data['status'] ?? null,
            'is_private' => in_array(data_get($data, 'is_private'), ['true', 1]),
            'properties' => $data['properties'] ?? [],
        ]);
    }


    public function replyComment($data, $comment)
    {
        $user = user() ?? null;

        $commentableClass = new CommentManager($comment, $user);

        $reply = $commentableClass->createComment([
            'body' => $data['body'],
            'properties' => $data['properties'],
            'status' => $data['status'] ?? null,
        ]);

        return $reply;
    }
}

Spamworldpro Mini