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/ts.corals.io/corals-api/Corals/modules/Utility/Traits/Comment/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/corals-api/Corals/modules/Utility/Traits/Comment/ModelHasComments.php
<?php

namespace Corals\Modules\Utility\Traits\Comment;

use Corals\Modules\Utility\Models\Comment\Comment;
use Illuminate\Database\Eloquent\Model;

trait ModelHasComments
{
    public static function bootModelHasComments()
    {
        static::deleted(function (Model $deletedModel) {
            if (schemaHasTable('utility_comments')) {
                $deletedModel->comments()->delete();
            }
        });
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
     */
    public function comments()
    {
        return $this->morphMany(Comment::class, 'commentable')->latest();
    }

    public function publishedComments()
    {
        return $this->comments()->where(function ($statusQuery) {
            $statusQuery->where('status', 'published')
                ->orWhereNull('status');
        });
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
     */
    public function comment_author()
    {
        return $this->morphTo('author');
    }
}

Spamworldpro Mini