<?php
namespace Koselig\Models;
use Illuminate\Database\Eloquent\Model;
use Koselig\Support\Wordpress;
class Comment extends Model
{
protected $table = DB_PREFIX . 'comments';
protected $primaryKey = 'comment_ID';
protected $dates = ['comment_date', 'comment_date_gmt'];
public $timestamps = false;
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
if (Wordpress::multisite() && (Wordpress::getSiteId() !== 0 && Wordpress::getSiteId() !== 1)) {
$this->setTable(DB_PREFIX . Wordpress::getSiteId() . '_comments');
}
}
public function post()
{
return $this->belongsTo(Post::class, 'comment_post_ID');
}
public function user()
{
return $this->belongsTo(User::class);
}
}