How to capitalize first letter in Laravel Blade
Use PHP's native ucfirst
function:
{{ ucfirst(trans('messages.welcome')) }}
Use Laravel helper Str::title()
{{ Str::title('messages.welcome') }}
Add a blade directive to the app/Providers/AppServiceProvider's boot() function:
public function boot() {
Blade::directive('lang_u', function ($s) {
return "<?php echo ucfirst(trans($s)); ?>";
});
}
This way you can use the following in your blade files:
@lang_u('messages.welcome')
which outputs: Welcome
You're @lang_u('messages.welcome') :)