<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Comentario extends Model
{
    use SoftDeletes;

    protected $table = "comentario";

    protected $dates = ['created_at','deleted_at'];

    protected $fillable = [
        'comentario',
        'id_tema',
        'id_usuario',
        'id_cita',
        'primer_comentario'
    ];

//    public function getParent() {
//        return $this->belongsTo(self::class, 'id_cita','id');
//    }
//
//    public function getChild(){
//        return $this->hasMany(self::class, 'id_cita','id');
//    }
    public function usuario()
    {
        return $this->belongsTo('App\Model\User','id_usuario')->withTrashed()
            ->select('id', 'nombres', 'apellido_paterno', 'apellido_materno');
    }

    public function childCita(){
        return $this->belongsTo(self::class,'id_cita')->withTrashed();
    }
    public function cita()
    {
        return $this->childCita()->with('cita','usuario')->withTrashed();
    }
//    public function scopeInfo($query)
//    {
//        return $query->with('cita');
//    }
}
