<?php
namespace App\Domain\Comments\Models;

use App\Models\User;
use App\Models\Model;
use App\Domain\Feeds\Models\Feed;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Domain\Complaints\Models\CommentComplaint;

class Comment extends Model
{

    use SoftDeletes;

    public function feed()
    {
        return $this->belongsTo(Feed::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function answer_to()
    {
        return $this->belongsTo(User::class, 'to_user_id');
    }

    public function parent()
    {
        return $this->belongsTo(Comment::class, 'parent_id');
    }
    public function children()
    {
        return $this->hasMany(Comment::class, 'parent_id');
    }


    public function complaints()
    {
        return $this->hasMany(CommentComplaint::class);
    }

}
