<?php

namespace CliqThemes\ORM\Entities;

use CliqThemes\ORM\Model;

/**
 * ORM model representing the wp_users table.
 */
class User extends Model
{
    protected string $table = 'users';

    protected string $primaryKey = 'ID';

    protected array $fillable = [
        'user_login',
        'user_pass',
        'user_nicename',
        'user_email',
        'user_url',
        'user_registered',
        'user_activation_key',
        'user_status',
        'display_name',
    ];

    protected bool $timestamps = false;

    /**
     * Relationship to user meta rows.
     */
    public function meta()
    {
        return $this->hasMany(UserMeta::class, 'user_id', 'ID');
    }

    /**
     * Relationship to posts authored by the user.
     */
    public function posts()
    {
        return $this->hasMany(Post::class, 'post_author', 'ID');
    }

    /**
     * Relationship to comments authored by the user.
     */
    public function comments()
    {
        return $this->hasMany(Comment::class, 'user_id', 'ID');
    }
}

