<?php

namespace app\model;

use DateTimeInterface;
use support\Model;

class MemberRole extends Model
{
    protected $table = 'member_role';

    protected $primaryKey = 'member_role_id';

    protected $keyType = 'string';

    protected $dateFormat = 'U';

    const CREATED_AT = 'member_role_addtimes';

    const UPDATED_AT = null;

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function category()
    {
        return $this->hasOne(SysCategory::class, 'category_id', 'join_member_role_category_id')
            ->select('category_id', 'category_name');
    }

    public function rulePricing()
    {
        return $this->hasOne(RulePricing::class, 'rule_pricing_id', 'join_member_role_rule_pricing_id')
            ->select('rule_pricing_id', 'rule_pricing_name');
    }
}