<?php
namespace app\common\model;

use think\model\Pivot;

class UserPart extends Pivot
{
	// 设置字段信息
    protected $schema = [
        'id'          		=> 'int',
		'puserid'			=> 'int',
		'userid'			=> 'int',
		'redmoney'			=> 'int',
		'status'			=> 'tinyint',
		'createtime'  		=> 'int'
    ];
	
	// 设置字段自动转换类型
	protected $type = [
		'createtime'  => 'timestamp:Y-m-d H:i:s'
    ];
	
	public function getStatusTextAttr($value,$data)
	{
		$status = [1=>'未入职', 2=>'已入职', 3=>'已发放'];
		return $status[$data['status']];
	}
	
	// 关联User
	public function puser()
	{
	    return $this->hasOne(User::class, "id", "puserid");
	}
	
	// 关联User
	public function user()
	{
	    return $this->hasOne(User::class, "id", "userid");
	}
	
	
}