<?php
namespace Koselig\Models;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Koselig\Support\Wordpress;
class User extends Model implements AuthenticatableContract
{
use Authenticatable;
protected $table = DB_PREFIX . 'users';
protected $primaryKey = 'ID';
protected $dates = ['user_registered'];
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() . '_users');
}
}
public function posts()
{
return $this->hasMany(Post::class, 'post_author');
}
public function getAuthPassword()
{
return $this->user_pass;
}
public function link()
{
return get_author_posts_url($this->ID, $this->display_name);
}
public function comments()
{
return $this->hasMany(Comment::class);
}
}