is there any way that instead of hard coding strings in the blade you use something like a string resource(or string table) so if you change a string every blade will be changed . For example instead of hoard coding "product" in the blade I use a variable called "string1" so if one day I change string1 value to "service" every blade will be affected and fine.
String Resource in laravel programming?
1.4k Views Asked by M.Shahrokhi At
4
There are 4 best solutions below
0
On
I am new to laravel but here is a idea I have.
create myString.php which contains your variables
example:
<?php
$string1 = "products";
?>
in your files
<?php
inlude_once("myString.php");
{{ $string1 }}
?>
I hope this helped you to come up with a better solution.
good luck.
0
On
As of Laravel 5.4, you can use the double underscore:
{{ __('Register') }}
What is nice about this is that you don’t need to do anything else for it to output (in this case) “Register”.
You can change what value is displayed either in the appropriate messages.php file or by creating a json file, as described in the docs.
maybe use localization with language files, so you can use
in a blade view. more info: https://laravel.com/docs/5.0/localization
and these 2 functions