protected function getSlugRecordFromCmsTable()
    {
        /** @var CmsModel|SluggableTrait $this */

        $languageId = $this->storeSlugForLanguageId();

        $entryId = $this->isTranslationModel()
            ?   $this->getAttribute(config('pxlcms.translatable.translation_foreign_key'))
            :   $this->getKey();

        $existing = DB::table(static::$slugsTable)
            ->select([ 'id', static::$slugsColumn . ' as slug' ])
            ->where(static::$slugsModuleKey, $this->getModuleNumber())
            ->where(static::$slugsEntryKey, $entryId);

        // if language is null, we need to take into account that some weird
        // cms hook setups will use '0' or '' (and do not have nullable language columns)
        if (is_null($languageId)) {

            $existing = $existing->where(function($query) {
                return $query->whereNull(static::$slugsLanguageKey)
                    ->orWhere(static::$slugsLanguageKey, 0)
                    ->orWhere(static::$slugsLanguageKey, '');
            });

        } else {

            $existing = $existing->where(static::$slugsLanguageKey, $languageId);
        }

        $existing = $existing->limit(1)
                             ->first();

        if (empty($existing)) return null;

        return $existing;
    }