Search for item with same slug.

@param mixed $model

@return bool
164395
private function slugExists(Model $model, $locale)
    {
        $query = $model::where('slug->'.$locale, $model->getTranslation('slug', $locale));
        if ($model->id) {
            $query->where('id', '!=', $model->id);
        }

        return (bool) $query->count();
    }
1332208
public function findBy(AbstractModel $model, $param = [])
    {
        if ($this->useCache && $this->modelCache) {
            if (($ret = $this->modelCache->get($model, $param))) {
                return $ret;
            }
        }

        list($query, $param, $type) = $this->queryBuilder->generateSelectForModel($model, $param);

        $result = $this->executeQuery(
            $model,
            $this->prepare(
                $query,
                $this->prepareParam($param)
            )
        );

        if ($this->useCache && $this->modelCache) {
            $this->modelCache->set($model, $param);
        }

        return $result;
    }
742713
public static function findBySlugOrFail($slug, array $columns = ['*'])
    {
        // Model not found, throw exception
        if (!$item = static::findBySlug($slug)) {
            throw (new ModelNotFoundException)->setModel(get_called_class());
        }

        // Return the model if visible
        $item->enforceVisibility();

        return $item;
    }
338113
public function findOneBy(AbstractModel $model, $param = [])
    {

        $result = $this->findBy($model, $param);
        $result->rewind();

        return $result->current();
    }
133523
public function doesSlugAlreadyExist($slug)
    {
        $rowCount = DB::table($this->model->table)
            ->where('slug',  $slug)
            ->count();

        if ($rowCount > 0) return $rowCount;
        return 0;
    }
1355236
protected static function hasCustomSearch($columnName)
    {
        $methodName = camel_case('laratables_search_'.$columnName);

        if (method_exists(self::$class, $methodName)) {
            return $methodName;
        }

        return false;
    }
791590
public function contains($model)
    {
        $class = $this->getClassMetadata(get_class($model));

        foreach ($class->getFieldManagerNames() as $manager) {
            if (!$this->pool->getManager($manager)->contains($model->{'get' . ucfirst($manager)}())) {
                return false;
            }
        }

        return true;
    }
256451
private function checkUpdatingSlug($slug)
    {
        if ($this->id >= 1) {

            $found = false;
            foreach ($this->uniqueModels() as $class) {

                // find entries matching slug, exclude updating entry
                $builder = $this->eloqent($class)->where('slug', $slug);

                // same model - exlude check
                if ($class == self::class) {
                    $builder = $builder->where('id', '!=', $this->id);
                }

                // found same slug - break, need new slug
                if ($found = $builder->first()) {
                    break;
                }
            }

            // save to use current slug for update
            if ($found == false || $found == null) {
                return $slug;
            }
        }

        // new unique slug needed
        return false;
    }
948933
public function contains(AbstractModel $model)
    {
        foreach ($this->storage as $key => $storedModel) {
            if ($model === $storedModel->getModel()) {
                return true;
            }
        }

        return false;
    }
892650
public function matchRelation($model, $results) {
        $data = [];
        foreach ($results as $item) {
            if (!$this->isMatchRelation($model, $item)) {
                continue;
            }
            if ($this->type == self::TYPE_ONE) {
                return $item;
            }
            $data[] = $item;
        }
        return $data;
    }
592720
public function hasUniqueSlug()
    {
        $hash = $this->slugWorkingRecord->{$this->slugDbField} ?: $this->encrypt();
        $list = $this->slugWorkingRecord->get()->filter($this->slugDbField, $hash);

        if($this->slugWorkingRecord->ID) {
            $list = $list->exclude('ID', $this->slugWorkingRecord->ID);
        }
        else {
            $list = $list->exclude('ID', 0);
        }

        return !($list->exists());
    }
898864
public function delete($model)
    {
        if ($model->files) {
            $model->files->each(function (File $file) {
                $file->delete();
            });
        }
        if ($model->delete()) {
            return true;
        }

        return false;
    }
6159
public function sameModels($firstModel, $secondModel)
    {
        foreach ($firstModel as $key => $value) {
            if ($key === $this->idProperty) {
                continue;
            }

            if (\is_array($value)) {
                if (!\is_array($secondModel->getProperty($key))) {
                    return false;
                }

                if (\serialize($value) !== \serialize($secondModel->getProperty($key))) {
                    return false;
                }
            } elseif ($value !== $secondModel->getProperty($key)) {
                return false;
            }
        }

        return true;
    }
232641
public function getLikedRecord(Model $model): ?Model
    {
        return $this->likes()
                    ->where('liked_by_id', $model->id)
                    ->where('liked_by_type', get_class($model))
                    ->first();
    }
867569
public function searchIndex($value)
    {
        foreach ($this->getGenerator() as $keyFromArray => $valueFromArray) {
            if ($value === $valueFromArray) {
                return $keyFromArray;
            }
        }

        return false;
    }
260548
protected function isQueryBuilder($model): bool
    {
        return $model instanceof \Illuminate\Database\Query\Builder
                    || $model instanceof \Illuminate\Database\Eloquent\Builder;
    }
265773
public function has($param)
    {

        if ($param instanceof \MongoId) {
            $id = (string) $param;
        } elseif ($param instanceof Model) {
            $id = (string) $param->getId();
        } elseif (is_string($param)) {
            $id = $param;
        }
        if ( isset($id) && isset($this->_items[$id]) ) {
            return true;
        }

        return false;

    }