已经有人在AdonisJ中使用过Hashids了吗?
更具体地说,在模型中,返回对象中的属性hashid
我正在做一个从拉拉维尔到阿多尼斯的迁移。在Laravel中,只需在每个模型中使用几行代码就可以了,如下所示:
use Hashids;
class Menu extends Model
{
use \OwenIt\Auditing\Auditable;
protected $appends = ['hashid'];
public function getHashidAttribute()
{
return Hashids::encode($this->attributes['id']);
}
}我安装了这个NPM软件包:https://www.npmjs.com/package/adonis-hashids,我试着找出如何像Laravel那样使用
发布于 2019-04-30 14:06:38
我使用了计算属性(properties)
class Menu extends Model {
static get computed () {
return ['hashids']
}
getHashids({ id }) {
return Hashids.encode(id)
}
}https://stackoverflow.com/questions/55906732
复制相似问题