Expand description
The string helpers the component IDs use, from the framework. String helpers, random strings, and identifiers.
Applications often turn a post’s title into a slug, a model’s name into a table name, or a
long comment into a preview. Str adds those helpers as methods on every string, and this
module’s functions make random strings, passwords, UUIDs, and ULIDs:
use laravel::str::Str;
assert_eq!("userName".snake(), "user_name");
assert_eq!("user_name".studly(), "UserName");
assert_eq!("Hello World!".slug(), "hello-world");
assert_eq!(Str::kebab("userName"), "user-name");
assert_eq!("photo".plural(), "photos");
let token = laravel::str::random(40);Str is in the prelude too, and works on Strings
through &str. See Strings.
Structs§
- Ulid
- A Ulid is a unique 128-bit lexicographically sortable identifier
- Uuid
- A Universally Unique Identifier (UUID).
Traits§
- Str
- String helpers for every
str, such as case conversions, slugs, substrings, shortening, padding, and plurals.
Functions§
- password
- Generates a random password of
lengthcharacters from letters, digits, and symbols. - random
- Generates a random string of
lengthletters and digits. - ulid
- Generates a ULID, a 26-character ID that holds the system time in milliseconds followed by random bits.
- uuid
- Generates a random version 4 UUID.
- uuid7
- Generates a version 7 UUID, which holds the system time in milliseconds followed by random bits.