Laravel String To Lower

Why not just use the PHP built-in strtolower?

<img src="images/{{ strtolower($matchup->visitorTeam) }}sml.jpg">

Or, if you need full UTF-8 support you can use mb_strtolower($string, 'UTF-8') which allows umlauts and other fun UTF-8 stuff. This is what Laravel's Str::lower() function does.


Because in the comments you asked still, how it works in the Laravel way, so here an alternative solution next to strtolower and mb_strtolower, which also work fine.

You have to add the namsepace in front of the method, that PHP and Laravel can find the method.

So, if you want to use it in Blade, do the following:

<img src="images/{{ Illuminate\Support\Str::lower($matchup->visitorTeam) }}sml.jpg">

If you want to use it in a Controller or Model, you have to add the namespace, where Str is in on the top:

use Illuminate\Support\Str;

After that, you can call it without the namespace prefix:

Str::lower($test);

Consider using mb_strtolower to be able to convert any character that has 'alphabetic' property, such as Č, Ć etc.