0

I'm building a CRM multitenacy application in laravel 9, where, when the tenant create a new customer I'm sending a welcome email to the customer.

Now i want to allow the user to create a custom message template using also variables.

For example, if the tenant has the following tag variables available :

[guest_name]
[check_in_date]
[check_out_date]

The tenant should be able to create a message template like:

Dear [guest_name], thank you very much for booking a room with us.
Your check in is expected on [check_in_date], while check out is expected on [check_out_date].

I'm getting crazy to understand how to do it, as it seems i cannot find anything similar online but I've seen it in many CRM before.

Is there anybody who can help me to understand how to do so or at least point me in the right direction to find informations on this type of feature?

Thank you very much.

Tim Lewis
  • 27,813
  • 13
  • 73
  • 102
Gianmarco
  • 69
  • 1
  • 9
  • Does this answer your question? [how to replace a placeholder in a string?](https://stackoverflow.com/questions/8718905/how-to-replace-a-placeholder-in-a-string) – N69S May 24 '22 at 16:22
  • 1
    Look at the answer using the placeholder `$format = "Hello, {NAME}!";`. you just need a list of possible place holders, loop them and str_replace with the according value. – N69S May 24 '22 at 16:23
  • This is similar to WordPress' shortcodes. You need to use regex with preg_replace() – Yousof K. May 25 '22 at 01:03

0 Answers0