Cviebrock\EloquentSluggable\Services\SlugService::getExistingSlugs PHP Method

getExistingSlugs() protected method

Get all existing slugs that are similar to the given slug.
protected getExistingSlugs ( string $slug, string $attribute, array $config ) : Collection
$slug string
$attribute string
$config array
return Illuminate\Support\Collection
    protected function getExistingSlugs($slug, $attribute, array $config)
    {
        $includeTrashed = $config['includeTrashed'];
        $query = $this->model->newQuery()->findSimilarSlugs($this->model, $attribute, $config, $slug);
        // use the model scope to find similar slugs
        if (method_exists($this->model, 'scopeWithUniqueSlugConstraints')) {
            $query->withUniqueSlugConstraints($this->model, $attribute, $config, $slug);
        }
        // include trashed models if required
        if ($includeTrashed && $this->usesSoftDeleting()) {
            $query->withTrashed();
        }
        // get the list of all matching slugs
        $results = $query->select([$attribute, $this->model->getTable() . '.' . $this->model->getKeyName()])->get()->toBase();
        // key the results and return
        return $results->pluck($attribute, $this->model->getKeyName());
    }