INTERNAL_TYPE::class ]; // attrlist start public static $attrlist = array ( 0 => 'id', 1 => 'admin_id', 2 => 'from_id', 3 => 'user_id', 4 => 'cate', 5 => 'is_read', 6 => 'status', 7 => 'type1', 8 => 'content', 9 => 'template_id', 10 => 'at_users', 11 => 'data', 12 => 'created_at', 13 => 'updated_at', 14 => 'deleted_at', ); //attrlist end protected $table = 'user_internals'; protected $appends = [ 'from_info' ]; public function getFromInfoAttribute() { if ($this->from_id == 0) { return [ 'nickname' => '管理员', 'avatar' => 1 ]; } $infos = UserService::pinfos([ $this->from_id ]); return $infos[$this->from_id] ?? [ 'nickname' => '未知', 'user_id' => $this->from_id, 'avatar' => 0 ]; } }