Check if we are updating
Find entries with same slug
Exlude current model's entry

@param $slug
@return bool
967035
private function checkUpdatingSlug($slug)
    {
        if ($this->id >= 1) {
            // find entries matching slug, exclude updating entry
            $exist = self::where($this->slugOptions->slugField, $slug)
                ->where('id', '!=', $this->id)
                ->first();

            // no entries, save to use current slug
            if (!$exist) {
                return $slug;
            }
        }

        // unique slug needed
        return false;
    }
598106
public function removeAction($slug)
    {
        if (array_key_exists($slug, $this->actions)) {
            unset($this->actions[$slug]);

            return true;
        } else {
            return false;
        }
    }
1293758
private function getSimilarSlugs(EntityManager $em, $slug)
    {
        if (!isset($this->similarSlugs[$slug])) {
            $this->similarSlugs[$slug] = $this->getSlugMapItemRepository($em)->getSimilarSlugs($slug);
        }

        return $this->similarSlugs[$slug];
    }
54062
public function deleteBySlug($slug)
    {
        $album = $this->findBySlug($slug);

        return $this->delete($album->id);
    }
795269
public function delete($slug)
    {
        if(is_object($slug) && $slug instanceof ModelObject)
            $slug = $slug->Slug;

        $this->Events->trigger(get_class($this).'.delete.pre', $this, $slug);
        $this->Events->trigger('AbstractSystemXMLDAO.delete.pre', $this, $slug);

        $this->loadSource();

        if(isset($this->objectsBySlug[$slug]))
        {
            $obj = $this->objectsBySlug[$slug];

            unset($this->objectsBySlug[$slug]);
            unset($this->slugsByID[$obj->AspectID]);

            $pKey = array_search($slug, $this->slugsByPluginID[$obj->PluginID]);
            unset($this->slugsByPluginID[$pKey]);

        }

        $this->persistSource();

        $this->Events->trigger(get_class($this).'.delete.post', $this, $slug);
        $this->Events->trigger('AbstractSystemXMLDAO.delete.post', $this, $slug);

        return true;
    }
674365
public function getEntity(string $slug): self
    {
        $this->entity = Dashboard::getEntities()->where('slug', $slug)->first();

        throw_if(is_null($this->entity), EntityTypeException::class, "{$slug} Type is not found");

        return $this;
    }
383816
public function block($slug)
    {
        $block = $this->findABlock($slug);

        if (!$block) {
            $this->update([
                'blocks' => json_encode(array_merge($this->blocks, [ $slug => '' ]))
            ]);
        }

        return $block;
    }
644575
public function getActive($slug)
    {
        $bc = $this->getBreadCrumb();
        foreach ($bc as $bcItem) {
            if ($bcItem->getSlug() == $slug) {
                return true;
            }
        }

        return false;
    }
746891
private function isSlugUnique($slug, $entityClass, $entityId, array $similarSlugs)
    {
        if (empty($similarSlugs)) {
            return true;
        }
        foreach ($similarSlugs as $similar) {
            if ($slug !== $similar['slug']) {
                continue;
            }
            if (empty($entityId)) {
                return false;
            }
            if (!($entityId == $similar['object_id']
                && ($entityClass === $similar['object_class'] || in_array($similar['object_class'], class_parents($entityClass))))
            ) {
                return false;
            }
        }

        return true;
    }
996617
public function may($slug)
    {
        return ! $this->permissions->filter(function (PermissionContract $permission) use ($slug) {
            return $permission->hasSlug($slug);
        })->isEmpty();
    }
206292
function updateSlug($category,$slug,$title){
        if($slug!='')
            $slug= $this->str_slug($slug);
        else
            $slug= $this->str_slug($title);

        if($category->slug==$slug)
            return $slug;
        else
            return $this->checkSlugInCategories($slug);
    }
208738
public static function getBySlug($slug)
    {
        $slug_parts = explode("-", $slug, 2);
        $class = get_called_class();
        $temp_this = new $class();
        $primary_key = $temp_this->getIDField();
        return self::search()->where($primary_key, $slug_parts[0])->execOne();
    }
56438
public static function checkSlug($slugField, $slug, $id = null)
    {
        $instance   = new static;

        $slug   = $slug;
        $query = $instance->where($slugField, $slug);

        if($id != null)
        {
            $query->whereNotIn($instance->getKeyName(), [$id]);
        }

        $nObjects = $query->count();

        if($nObjects > 0)
        {
            $suffix = 0;
            while($nObjects > 0)
            {
                $suffix++;
                $slug       = $slug . '-' . $suffix;
                $nObjects   = $instance->where($slugField, $slug)->count();
            }
        }

        return $slug;
    }
649486
public function slugExists(Model $model, $slug) {
        return (bool) $model->find('count', array(
            'conditions' => array($this->settings[$model->alias]['slug'] => $slug),
            'recursive' => -1,
            'contain' => false
        ));
    }
300096
function checkSlugInCategories($slug){
        $repet=true;
        $counter=1;
        $newSlug=$slug;

        while ($repet)
        {
            if(Categories::where('slug',$newSlug)->where('model_type',$this->type)->first())
            {
                $newSlug=$slug.'-'.$counter;
                $counter++;
            }
            else
                $repet=false;
        }

        return $newSlug;
    }
534188
public function get($slug)
    {
        return $this->ports->first(function (Port $port) use ($slug) {
            return $port->slug() === $slug;
        });
    }
917243
public function checkIfSlugIsUnique($slug)
    {
        $i = 0;
        $this->base_slug = $slug;

        while ($this->post->whereSlug($slug)->get()->count() > 0) {
            $i++;
            $slug = "$this->base_slug-$i";
        }

        return $slug;
    }