Put variables in plain text

0

Hello good afternoon, sorry, I can put a Laravel variable of some model in a plain text, for example:

$mensaje->cuerpomensaje

has this message by default

Hola [usuario] te damos la bienvenida.

How can I do so that in the [usuario] the name of the user, for example logeado or the name of some other user that I choose, appears.

    
asked by karloz eduardo 27.06.2018 в 00:34
source

1 answer

0

You could use the php explode function to split your message body by removing the sample text and then join the elements of the array that generates you with the data you want, for example the name of the logged-in user:

$string = explode("[usuario]", $mensaje->cuerpomensaje);

$texto_a_mostrar = $string[0] . auth()->user()->name . $string[1];

// Hola Karloz Eduardo te damos la bienvenida
    
answered by 27.06.2018 в 00:59