Many sites need to show their subpages under generated nice friendly URL addresses representing records in the database, instead of selecting records by their id.

Generating slugs

CrudAdmin generates slugs from database values through the $sluggable property of the admin model.
app/Article.php
$sluggable holds the column the URL addresses are generated from. A helper column named slug is created in the database, holding the generated value after the record is created or updated.
Generated slug column in the database table
If the generated slug already exists in the database, an incremental value is appended. Three records named My article produce the slugs my-article, my-article-1 and my-article-2.

Multilanguage slugs

If the field carries the locale parameter, which translates the record into several languages, the slug column is stored as JSON, where each language holds its own slug.
Slug column stored as JSON with a value per language
If the record has no translation in the administration, CrudAdmin falls back to the slug of the main language, or any available translated value.
Translating records and texts is covered in Localization.

Selecting a record by its slug

By slug

In the controller, use findBySlug() or findBySlugOrFail() to look up the record by the slug passed as a URL parameter.
app/Http/Controllers/ArticleController.php

By slug and id

A record can also be selected by its slug and id at once. When findBySlug or findBySlugOrFail receives the record id as its second argument, it verifies the slug from the URL and redirects the client to the correct address with a 301 header if it does not match.
app/Http/Controllers/ArticleController.php

Reading the slug value

Use $article->getSlug() to access the generated slug of a record.