Laravel 5 String Helpers: Getting the Singular Form of a String Value Dec 6, 2017
The singular method is used to return the singular form of a given word. It is the opposite of the plural method. The method follows similar internal mechanisms as the plural method. There are certain words and word endings that are not affected by this method. The str_singular function is a global helper function that can be used instead of Str::singular.
Laravel 5 String Helpers: Parse Callback Dec 6, 2017
Learn how to use the parseCallback method in Laravel to break a string into a class name and method name. This method is helpful when working with class names and method names that are separated by the @ symbol. You can also specify a default method name to be used if there is no @ symbol or if nothing is on the right side of it. The function returns an array with the class name as the first element and the method name as the second element.
Laravel 5 String Helpers: Pluralization and Strings Dec 6, 2017
The plural helper method in Laravel returns a plural version of a given value. It applies general rules to strings to handle common cases, but also has special cases that it does not attempt to pluralize. Starting with version 5, Laravel uses the doctrine/inflector package for word inflections. The plural method takes a value and an optional count. It can be used to pluralize words in different scenarios, such as displaying message counts to users. There are special cases and word patterns that are not pluralized by the plural method, and Laravel also provides a global str_plural helper function as a shortcut to calling Str::plural.
Laravel 5 String Helpers: Replacing the First Occurrence of a Value Dec 6, 2017
The replaceFirst helper method allows you to replace the first occurrence of a given string with another string in a target string. All three parameters are required and must be strings. An example use of this method is replacing the protocol in a URL. Additionally, there is a global str_replace_first helper function available for convenience.
Laravel 5 String Helpers: Replacing the Last Occurrence of a Value Dec 6, 2017
The replaceLast helper method is used to replace the last occurrence of a given string with another string in a larger string. It is the opposite of the replaceFirst method. All three parameters must be strings and are required. An example use of this method includes replacing the last occurrence of a word in a sentence. In addition, there is a global str_replace_last helper function available which provides a shortcut for calling the replaceLast method.
Laravel 5 String Helpers: ends_with global helper Dec 6, 2017
The endsWith method in Laravel's Str class is used to check if a given string ends with any of the supplied characters. It returns true if the string ends with any of the characters, and false otherwise. You can use the endsWith method directly or the global ends_with helper function for convenience.
Checking if a String Ends with a Particular Value in Laravel -Laravel 5.5 String Helper Method: endsWith Nov 30, 2017
The endsWith method in Laravel's Str class is used to check if a string ends with any of the supplied characters. It returns true if the string ends with any of the characters and false otherwise. You can also use it to check if a string ends with any alphabetical character by combining it with PHP's range function. Additionally, there is a global function called ends_with that serves as a shortcut to calling Str::endsWith.
Generating URLs from Strings in Laravel - Laravel 5.5 String Helper Method "slug" Nov 30, 2017
The slug method in Laravel's Str class allows you to format a given title into a URI slug. It will convert the title to ASCII characters, replace whitespace with a separator, and reduce multiple separators to a single one. It will also trim any leading or trailing whitespace or separators. The slug method has a default separator of "-", but you can customize it as well as specify the language. Additionally, Laravel provides a global str_slug helper function as a shortcut to calling Str::slug.
Laravel 5.5 String Helper Method: contains Nov 30, 2017
The contains method in Laravel's Illuminate\Support\Str class allows you to check if any given elements exist within a string. By passing in a string and an array of elements, the method will return true if any of the elements are found in the string, and false otherwise. The method takes into account the case of both the string and the elements. Additionally, Laravel provides a global str_contains helper function that serves as a shortcut to calling Str::contains.
Laravel 5.5 String Helper Method: finish Nov 30, 2017
The finish helper method ensures that a given value always ends with a provided character or string. This is especially useful when constructing URIs or file paths. The method can be combined with other string manipulation methods, like slug, to generate interesting results. Additionally, there is a global str_finish helper function that provides a shortcut to calling Str::finish.
Laravel 5.5 String Helper Method: kebab Nov 30, 2017
The snake helper method is used to replace uppercase letters in a string with their lowercase variant, preceded by a - character. However, if the first character of the string is capitalized, it will be replaced without the - character. The kebab method removes excess whitespace from a string that is being converted. Both methods can be used interchangeably when using the - delimiter. Additionally, the kebab_case function serves as a shortcut for calling the Str::kebab method.
Laravel 5.5 String Helper Method: snake Nov 30, 2017
The snake helper method in Laravel replaces all uppercase letters within a string with the lowercased variant, while prefixing them with a given delimiter. However, if the first character of the string is already capitalized, it will be replaced by the corresponding lowercased variant without the delimiter. The method also trims any extra whitespace from the string being converted. Additionally, there is a global snake_case helper function available, which is a shortcut to calling Str::snake.
Laravel 5.5 String Helper Method: title Nov 30, 2017
This method allows you to convert a given value into a traditional print title format. It converts the value to lowercase and capitalizes the first character of each word. Note that it may change the case of every character in the string. In addition to the title method, you can also use the global title_case helper function as a shortcut for calling Str::title.