The Blog

Laravel 5

Laravel 5

Laravel 5.5 String Helper Method: snake

John Koster
John Koster
November 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

Laravel 5.5 String Helper Method: title

John Koster
John Koster
November 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.

Laravel 5

Laravel String Pattern Matching - Laravel 5.5 String Helper Method: "is"

John Koster
John Koster
November 30, 2017

The is helper method in Laravel's Illuminate\Support\Str class checks if a given value matches a given pattern. It returns true if the value matches the pattern and false otherwise. The method does not support traditional regular expressions. Laravel also provides a global str_is helper function that is a shortcut to calling Str::is.

Laravel 5

Making Sure Strings Start With a Given Value in Laravel - Laravel 5.5 String Helper Method: start

John Koster
John Koster
November 30, 2017

The start helper method ensures that a given value begins with exactly one occurrence of a prefix. It can be useful for generating absolute URLs from relative paths. The prefix can be any string value. Additionally, there is a global str_start helper function that provides a shortcut for calling Str::start.

Laravel 5

Laravel 5.5 String Helper Function: after

John Koster
John Koster
November 27, 2017

Learn how to use the after method in Laravel's Illuminate\Support\Str class to extract a substring after the first occurrence of a specified character. This method is useful for parsing URL query strings or quickly finding substrings based on a certain character. Use the provided signature and example to get started.

Laravel 5

Laravel 5.5 String Helper Function: before

John Koster
John Koster
November 27, 2017

The before method in Laravel's Illuminate\Support\Str class allows you to retrieve a portion of a string before the first occurrence of a specified character. It is useful for parsing URL query strings or extracting substrings. For example, Str::before('https://stillat.com?ref=newsletter', '?') would return "https://stillat.com".

Laravel 5

Laravel 5.5 String Helper Function: camel_case

John Koster
John Koster
November 27, 2017

The camel method in Laravel's Str class converts a string to camel case, where each word starts with a capitalized letter, except the first character, which is lowercased. It ignores special characters and spaces. The camel_case function is a shorthand for using Str::camel globally.

Laravel 5

Laravel 5.5 String Helper Function: studly

John Koster
John Koster
November 27, 2017

Learn how to format text using studly caps in Laravel. Studly caps removes word separators and capitalizes the first letter of each word. See examples of how the studly method works and how it can be used to generate Pascal Cased style strings. Also, find out about the global studly_case helper function that calls the Str::studly method.

Laravel 5

Laravel 5.5 String Helper Function: ascii

John Koster
John Koster
November 27, 2017

The ascii helper method converts a string in UTF-8 encoding into its ASCII equivalent. It is useful when communicating with software platforms that require ASCII or complying with formatting protocols. The method accepts a language parameter, and in Laravel 5.5, it supports Bulgarian and German in addition to English. The method can be used by passing a string to it and will return the ASCII representation of that string.

Latest posts

That Escalated Quickly: All the New Things

The past six months or so have been incredibly busy. What started as a new article series about cust...

Read more
Troubleshooting a Statamic Illegal Offset Type Error when Viewing Collection Entries in the Control Panel

In this post I talk about how I resolved a mysterious illegal offset type error when viewing collect...

Read more
Creating Simple HTTP Redirect Routes from a Statamic Site

Generating a custom Laravel routes file from a Statamic website to redirect to a new domain.

Read more
Disabling Vite File Hashes

Disabling file hashes in Vite output can be accomplished by modifying your project's vite.config.js

Read more
Implementing a Custom Laravel Blade Precompiler for Volt and Livewire

Learn how to implement a custom component compiler for Laravel's Blade templating language in this p...

Read more
Creating a Hybrid Cache System for Statamic: Part Five

Part 5 of 6 covers implementing a cache namespace and labeling system, which we can use to target mu...

Read more