mardi 6 février 2018

Dynamically call Lang::get with a JS variable in a .blade.php template file

Because it's difficult to explain properly, here's what I'm trying to do:

test.blade.php

//Above there is blade code

<script type="text/javascript">
    foreach (test in tests) {
       console.log("{!! Lang::get('message.$test.name') !!}")
    }
</script>

So $test is a JS variable which has a value in message.php. If I replace $test with the valure as a string, it works correctly. Is there any way to use a variable inside the Lang::get call?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire