<?php

namespace ZenoChatbot\Model;

use ZenoChatbot\Framework\Database\Model;

/**
 * User Model
 *
 * Represents WordPress users (wp_users table)
 */
class User extends Model
{
    /**
     * Table name (WordPress users table)
     */
    protected $table = 'users';

    /**
     * Primary key
     */
    protected $primaryKey = 'ID';

    /**
     * WordPress users table doesn't use timestamps
     */
    public $timestamps = false;

    /**
     * Fillable attributes (limited for WordPress compatibility)
     */
    protected $fillable = [
        'user_login',
        'user_email',
        'user_nicename',
        'display_name'
    ];

    /**
     * Attributes that should be cast
     */
    protected $casts = [
        'ID' => 'int',
        'user_registered' => 'datetime'
    ];

    /**
     * Hidden attributes (security)
     */
    protected $hidden = [
        'user_pass',
        'user_activation_key'
    ];

    /**
     * Get the table name with WordPress prefix
     */
    public function getTable(): string
    {
        global $wpdb;
        return $wpdb->users;
    }

    /**
     * Get customer record associated with this user
     * Application-side relationship
     */
    public function customer()
    {
        return $this->hasOne(Customer::class, 'user_id');
    }
}
