Used in implicit model binding AND
used in explicit model binding if no callback
is specified, eg: Route::model('post', Post::class)

@param  string $slug
@return \Illuminate\Database\Eloquent\Model
554470
public function resolveRouteBinding($slug){
		$id = static::decodeSlug($slug);
		return parent::where($this->getKeyName(), $id)->first();
	}
746385
public function getLog($slug)
    {
        foreach ($this->logs as $log) {
            if ($log->getSlug() == $slug) {
                return $log;
            }
        }
    }
487942
public function findBySlug($slug)
    {
        return $this->slugWorkingRecord->get()->filter($this->slugDbField, $slug)->first();
    }
869919
public function view($slug = null)
    {
        //Data can be passed as query string, from a widget
        if ($this->request->getQuery('q')) {
            return $this->redirect([$this->request->getQuery('q')]);
        }

        $slug = Text::slug($slug, ['replacement' => ' ']);

        $tag = $this->PostsTags->Tags->findActiveByTag($slug)
            ->cache((sprintf('tag_%s', md5($slug))), $this->PostsTags->getCacheName())
            ->firstOrFail();

        $page = $this->request->getQuery('page', 1);

        //Sets the cache name
        $cache = sprintf('tag_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($posts, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->PostsTags->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($posts) || empty($paging)) {
            $query = $this->PostsTags->Posts->find('active')
                ->find('forIndex')
                ->matching($this->PostsTags->Tags->getAlias(), function (Query $q) use ($slug) {
                    return $q->where(['tag' => $slug]);
                });
            $posts = $this->paginate($query);

            //Writes on cache
            Cache::writeMany([
                $cache => $posts,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->PostsTags->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set(compact('posts', 'tag'));
    }
501641
public function actionCreate($slug)
    {
        $current_model = $this->module->getModel($slug);

        if ($current_model->load(Yii::$app->request->post())) {
            if(Yii::$app->request->isAjax){
                Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
                return ActiveForm::validate($current_model);
            }
            else{
                if(isset($_FILES)){
                    $this->saveFiles($current_model);
                }

                if($current_model->save()){
                    $this->flash('success', Yii::t('gr', 'Post created'));
                    return $this->redirect([Url::previous()]);
                }
                else{
                    $this->flash('error', Yii::t('gr', 'Error'));
                    return $this->refresh();
                }
            }
        }
        else {
            return $this->render('@grozzzny/base_module/views/a/create', [
                'current_model' => $current_model
            ]);
        }
    }
479313
public function view($slug = null)
    {
        //The category can be passed as query string, from a widget
        if ($this->request->getQuery('q')) {
            return $this->redirect([$this->request->getQuery('q')]);
        }

        $page = $this->request->getQuery('page', 1);

        //Sets the cache name
        $cache = sprintf('category_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($posts, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->PostsCategories->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($posts) || empty($paging)) {
            $query = $this->PostsCategories->Posts->find('active')
                ->find('forIndex')
                ->where([sprintf('%s.slug', $this->PostsCategories->getAlias()) => $slug]);

            is_true_or_fail(!$query->isEmpty(), I18N_NOT_FOUND, RecordNotFoundException::class);

            $posts = $this->paginate($query);

            //Writes on cache
            Cache::writeMany([
                $cache => $posts,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->PostsCategories->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set('category', $posts->extract('category')->first());
        $this->set(compact('posts'));
    }
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;
    }
411830
public function find($slug, array $columns = ['*'])
    {
        $model = $this->model;

        return $model::where('slug', '=', $slug)->first($columns);
    }
1216037
public function findOneBySlug($slug)
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.slug = :slug')
            ->setParameter('slug', $slug)
            ->andWhere('c.publishAt < :now OR c.publishAt IS NULL')
            ->andWhere('c.active = :active')
            ->andWhere('c.layout = :layout')
            ->setParameter('now', new \DateTime())
            ->setParameter('active', true)
            ->setParameter('layout', false)
            ->setMaxResults(1)
            ->getQuery();

        return $query->useResultCache(true, self::CACHE_TTL)->getOneOrNullResult();
    }
1020264
public function show($slug)
	{
		$post = $this->posts->findBySlug($slug);

		if ( ! $post)
		{
			return App::abort(404, 'Page not found');
		}

		return View::make($this->theme.'.post', compact('post'));
	}
315884
public function retrieveActiveBySlug($slug)
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.isActive = :isActive')
            ->andWhere('c.slug = :slug')
            ->orderBy('c.rank', 'ASC')
            ->setMaxResults(1)
            ->getQuery();

        $query->setParameter('isActive', true);
        $query->setParameter('slug', $slug);

        return $query->getOneOrNullResult();
    }
642153
public function getRoute($slug)
    {
        $key = md5($slug);
        $dbRoute = Yii::$app->cache->get($key);
        if (YII_ENV_DEV || $dbRoute == false) {
            $dbRoute = UrlRule::getRouteBySlug($slug);
            Yii::$app->cache->set(
                $key,
                $dbRoute
            );
        }
        return $dbRoute;
    }
279340
protected function rollback($slug)
    {
        if (! $this->packages->exists($slug)) {
            return $this->error('Package does not exist.');
        }

        $this->requireMigrations($slug);

        //
        $this->migrator->setConnection($this->input->getOption('database'));

        $pretend = $this->input->getOption('pretend');

        $this->migrator->rollback($pretend, $slug);

        //
        foreach ($this->migrator->getNotes() as $note) {
            if (! $this->option('quiet')) {
                $this->line($note);
            }
        }
    }
423389
public function actionView($id = 0, $slug= '')
    {
        $model = $this->findModel($id, $slug);
        if (\Yii::$app->user->can('viewPost', ['post' => $model])) {
            return $this->render('view', [
                'model' => $model,
            ]);
        } else
            throw new ForbiddenHttpException(Module::t('core', 'Access denied.'));
    }
1171097
function (slug) {
        var query = { where: {} };
        query.where[slugColumn] = slug;

        return Model.findOne(query).then(function (model) {
            return model === null;
        });
    }
1292385
protected function getPage($slug)
    {
        // get page by slug
        $page = $this->model->getPage($slug);

        if (is_null($page)) {
            abort(404);
        }

        //Set theme variables
        $view = $page->view;
        $view = view()->exists('page::' . $view) ? $view : 'default';

        if ($page->compile) {
            $page->content = blade_compile($page->content);
        }

        return $this->response
            ->setMetaKeyword(strip_tags($page->meta_keyword))
            ->setMetaDescription(strip_tags($page->meta_description))
            ->setMetaTitle(strip_tags($page->meta_title))
            ->view('page::' . $view)
            ->data(compact('page'))
            ->output();

    }
1158940
protected function migrate($slug)
    {
        $moduleName = Str::studly($slug);
        if ($this->pluggable->exists($moduleName)) {
            $pretend = $this->option('pretend');
            $path = $this->getMigrationPath($slug);
            $this->migrator->run($path, $pretend);

            foreach ($this->migrator->getNotes() as $note) {
                if (!$this->option('quiet')) {
                    $this->output->writeln($note);
                }
            }

            if ($this->option('seed')) {
                $this->call('pluggable:seed', ['pluggable' => $slug, '--force' => true]);
            }
        } else {
            return $this->error("Pluggable [$moduleName] does not exist.");
        }
    }