How to capitalize the first letter in Laravel Blade Views?
Hey there!
What I usually do is to use the ucfirst()
PHP function directly in your Blade view.
To do that in your view directly, you can use the following syntax:
{{ ucfirst('your string here') }}
Or you could even pass in a variable if you had to:
{{ ucfirst($user->first_name) }}
For more information make sure to check out the official documentation here:
https://laravel.com/docs/8.x/helpers#method-str-upper
Hope that this helps!
















@bobbyiliev wrote a good answer. But if you want to use pure PHP you can always do that.
{{ mb_strtoupper(mb_substr($user->first_name, 0, 1)) . mb_substr($user->first_name, 1) }}
Which is really what ucfirst()
does under the hood. But you can use pure PHP functions in your blade files so wanted to point this out too. 🙂
















