Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capitalized a blade's variable in Laravel

I used to use smarty a lot and now moved on to Laravel but I'm missing something that was really useful. The modification in the template of you're variable.

Let say I have a variable assign as {{$var}}. Is there a way in Laravel to set it to upper case ? Something like: {{$var|upper}}

I sadly haven't found any documentation on it.

like image 550
Baldráni Avatar asked Nov 30 '22 23:11

Baldráni


2 Answers

Only first character :

You could use UCFirst, a PHP function

{{ucfirst(trans('text.blabla'))}}

For the doc : http://php.net/manual/en/function.ucfirst.php


Whole word

Str::upper($value)

Also this page might have handy things : http://cheats.jesse-obrien.ca/

like image 96
Alexandre Beaudet Avatar answered Dec 11 '22 12:12

Alexandre Beaudet


PHP Native functions can be used here

{{ strtoupper($currency) }} 

{{ ucfirst($interval) }}

Tested OK

like image 35
mujuonly Avatar answered Dec 11 '22 12:12

mujuonly