User::class, 'foreign_key' => 'user_id' ]; $config['registered_callbacks']['before_store'][] = 'cbGenerateAlias'; parent::configure($config); } public function cbGenerateAlias(string $event) { if (!$this->alias) { //Generate the alias from the ID. $hash_id = new Hashids($GLOBALS['UNI_NAME_CLEAN'], 8); $this->alias = $hash_id->encode($this->id); } } }