'int', 'userid' => 'int', 'title' => 'string', 'intvalue' => 'int', 'intmoney' => 'float', 'onlycontent' => 'string', 'remark' => 'string', 'itype' => 'tinyint', 'status' => 'tinyint', 'createtime' => 'int', 'yeartime' => 'int', 'monthtime' => 'int' ]; // 设置字段自动转换类型 protected $type = [ 'createtime' => 'timestamp:Y-m-d H:i:s' ]; public function getItypeTextAttr($value,$data) { $itype = [1=>'推荐奖励', 2=>'积分充值', 3=>'积分兑现', 4=>'招聘相关', 5=>'订单相关', 6=>'供人相关', 7=>'兑购消费', 8=>'其他']; return $itype[$data['itype']]; } public function getStatusTextAttr($value,$data) { $status = [1=>'待处理', 2=>'已处理']; return $status[$data['status']]; } // 关联User public function user() { return $this->hasOne(User::class, "id", "userid"); } }